java XmlDocument

可以参考的资料:
http://blog.csdn.net/icecloud/article/details/7795


需要引入的包为:
jaxen
xmlpull
xstream
dom4j


import
java.io.File; import java.util.List; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class TestXpath { @SuppressWarnings("unchecked") public static void main(String[] args) { try { SAXReader reader = new SAXReader(); Document document = reader.read(new File("config.xml")); String xml=document.asXML(); System.out.println(xml); List<Element> list = document.selectNodes("//page"); for (Element epage : list) { System.out.println(epage); } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }

 

你可能感兴趣的:(document)