按照指定路径获取xml节点信息

String xmlpath = ParseXML.class.getResource("peopleInfo.xml").toString();   
        SAXReader reader = new SAXReader();   
        Document document = reader.read(xmlpath);   
        List projects = document.selectNodes("//person/company/name");   
        Iterator it = projects.iterator();   
        while (it.hasNext()) {   
            Element elm = (Element) it.next();   
            System.out.println(elm.getText());   
        }

你可能感兴趣的:(java,xml)