研究 JAVA & XML 的朋友来报个名吧!

keer 2002-03-26 12:56:48
KEER QQ:69752684
EMAIL:WANGLU107@HOTMAIL.COM
...全文
114 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
baobaoking 2002-03-28
  • 打赏
  • 举报
回复
me
RDFS & XML & Java:)

email:zz_email@21cn.com
ttt 2002-03-26
  • 打赏
  • 举报
回复
http://www.csdn.net/Expert/TopicView1.asp?id=600786

请大家帮忙,多谢。
bill_hongs 2002-03-26
  • 打赏
  • 举报
回复
//a sample for java +xml

import javax.xml.parsers.*;
import org.w3c.dom.*;

public class xmldisplay{

public static void main(String[] args){
try{
/**DocumentBuilderFactory
a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents
*/
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
/**DocumentBuilder
the API to obtain DOM Document instances from an XML document. Using this class, an application programmer can obtain a Document from XML
*/
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc=builder.parse("link.xml");
/** Document.normalize();
对Document对象调用normalize(),
可以去掉XML文档中作为格式化内容的空白而映射在DOM树中的不必要的Text Node对象
*/
doc.normalize();
/** Document.getElementsByTagName(String)
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree
*/
NodeList links=doc.getElementsByTagName("link");
for (int i=0;i<links.getLength();i++){
Element link=(Element) links.item(i);
System.out.print("Content: ");
System.out.println(link.getElementsByTagName("text").item(0).getFirstChild().getNodeValue());
System.out.print("URL: ");
System.out.println(link.getElementsByTagName("url").item(0).getFirstChild().getNodeValue());
System.out.print("Author: ");
System.out.println(link.getElementsByTagName("author").item(0).getFirstChild().getNodeValue());
System.out.print("Date: ");
Element linkdate=(Element) link.getElementsByTagName("date").item(0);
String day=linkdate.getElementsByTagName("day").item(0).getFirstChild().getNodeValue();
String month=linkdate.getElementsByTagName("month").item(0).getFirstChild().getNodeValue();
String year=linkdate.getElementsByTagName("year").item(0).getFirstChild().getNodeValue();
System.out.println(day+"-"+month+"-"+year);
System.out.print("Description: ");
System.out.println(link.getElementsByTagName("description").item(0).getFirstChild().getNodeValue());
System.out.println();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}//*end main

}
//end class

link.xml

<?xml version="1.0" standalone="yes"?>
<links>
<link>
<text>JSP Insider</text>
<url newWindow="no">http://www.jspinsider.com</url>
<author>JSP Insider</author>
<date>
<day>2</day>
<month>1</month>
<year>2001</year>
</date>
<description>A JSP information site.</description>
</link>
<link>
<text>The makers of Java</text>
<url newWindow="no">http://java.sun.com</url>
<author>Sun Microsystems</author>
<date>
<day>3</day>
<month>1</month>
<year>2001</year>
</date>
<description>Sun Microsystem's website.</description>
</link>
<link>
<text>The standard JSP container</text>
<url newWindow="no">http://jakarta.apache.org</url>
<author>Apache Group</author>
<date>
<day>4</day>
<month>1</month>
<year>2001</year>
</date>
<description>Some great software.</description>
</link>
</links>

redstarstar 2002-03-26
  • 打赏
  • 举报
回复
我我我。
xing_xing@263.net
keer 2002-03-26
  • 打赏
  • 举报
回复
to:firefoxyu(鱼儿)
<XML揭密-入门`应用`精通>书不错
keer 2002-03-26
  • 打赏
  • 举报
回复
to:hairinwind(hairinwind)
如果可以留下联系方式,便于交流
firefoxyu 2002-03-26
  • 打赏
  • 举报
回复
我也想学xml,但却无从着手,可否提供些资料?多谢!
keer 2002-03-26
  • 打赏
  • 举报
回复
谢谢支持
小妹最近在做这方面的东西,主要是用xml实现dbms
希望多与人交流.
belli_lanlan 2002-03-26
  • 打赏
  • 举报
回复
Count me in
belli_lan@etang.com

hairinwind 2002-03-26
  • 打赏
  • 举报
回复
在上海
trls 2002-03-26
  • 打赏
  • 举报
回复
想学,讲讲?
bill_hongs 2002-03-26
  • 打赏
  • 举报
回复
正在边学边用呢。
Where are you from?
hairinwind 2002-03-26
  • 打赏
  • 举报
回复
正在学习 jaxb

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧