------show.xml<?xml version="1.0" encoding="GB2312" standalone="no"?>
<PhoneInfo>
<Brand name="华为">
<Type name="U8650">
<Item>
<title>标题信息</title>
<link>链接</link>
<description>标题信息</description>
<pubDate>2014-11-1</pubDate>
</Item>
</Type>
<Type name="HW123"/>
<Type name="HW321"/>
</Brand>
<Brand name="苹果">
<Type name="iPhone4"/>
</Brand>
</PhoneInfo>
--------test.javatry{ //1创建解析器工厂对象 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); //2.通过解析器工厂对象创建解析器对象 DocumentBuilder db = dbf.newDocumentBuilder(); //3.通过解析器对象解析xml文档,并创建doc对象 Document doc = db.parse("src/show.xml"); //4.读取pubDate NodeList list = doc.getElementsByTagName("pubDate"); //4.1读取pubDate的元素节点 Element pubElement =(Element) list.item(0); //4.2读取pubDate的文本节点 String pubDateValue = pubElement.getFirstChild().getNodeValue(); System.out.println(pubDateValue); }catch(Exception e){ e.printStackTrace(); }