http://www.cnblogs.com/bmaker/p/5605738.html
XPath 是一门在 XML 文档中查找信息的语言。XPath 可用来在 XML 文档中对元素和属性进行遍历。
public class TransferXML {
- public static void main(String[] args) throws Exception{
- SAXReader saxReader = new SAXReader();
- File file = new File("D: est.xml");
- Document document = saxReader.read(file);
- Map map = new HashMap();
- map.put("design","http://www.eclipse.org/birt/2005/design");
- XPath x = document.createXPath("//design:list-property");
- x.setNamespaceURIs(map);
- List nodelist = x.selectNodes(document);
- System.out.println(nodelist.size());
- }
- }