當 xml中存在名稱空間,三種處理辦法(dom4j)
阿新 • • 發佈:2019-02-01
{
Map map = new HashMap();
map.put( " design " , " http://www.eclipse.org/birt/2005/design " );
SAXReader saxReader = new SAXReader();
File file = new File( " D:/test.xml " );
Document document = saxReader.read(file);
XPath x = document.createXPath(
"
//design:list-property
"
);
x.setNamespaceURIs(map);
List nodelist = x.selectNodes(document);
System.out.println(nodelist.size());
}
Map map = new HashMap();
map.put( " design " , " http://www.eclipse.org/birt/2005/design " );
SAXReader saxReader = new SAXReader();
File file = new File( " D:/test.xml " );
Document document = saxReader.read(file);
XPath x = document.createXPath(
x.setNamespaceURIs(map);
List nodelist = x.selectNodes(document);
System.out.println(nodelist.size());
}