1. 程式人生 > >當 xml中存在名稱空間,三種處理辦法(dom4j)

當 xml中存在名稱空間,三種處理辦法(dom4j)

{
        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());
    }