---------------------------------------------------------
SAXReader reader = new SAXReader();
try {
Document doc = reader.read("src/main/java/test.xml");
List items = doc.selectNodes("/file/chapter");
Iterator it = items.iterator();
while (it.hasNext()) {
Element el = (Element) it.next();
if ((!(el.attributeValue("id") == null) || !el.attributeValue(
"id").equalsIgnoreCase(""))) {
}
Attribute attId = el.attribute("id");
System.out.print("id:" + attId.getValue() + " ");
Attribute attName = el.attribute("name");
System.out.println("name:" + attName.getValue());
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
----------------------------------------------------
xsi:schemaLocation=" ">
4.0.0
com.travelsky.dom4j
dom4jProj
jar
1.0-SNAPSHOT
dom4jProj
junit
junit
3.8.1
test
dom4j
dom4j
1.6.1
provided
icu4j
icu4j
2.6.1
provided
jaxen
jaxen
1.1.1
provided
jdom
jdom
1.0
compile
xalan
xalan
2.6.0
compile
xerces
xercesImpl
2.6.2
provided
xml-apis
xml-apis
1.0.b2
provided
xerces
xmlParserAPIs
2.6.2
provided
xom
xom
1.0
compile
dom4jApp
org.apache.maven.plugins
maven-compiler-plugin
1.4
UTF-8
org.apache.maven.plugins
maven-javadoc-plugin
UTF16
阅读(2007) | 评论(0) | 转发(0) |