/ Published in: Java
URL: http://www.ibm.com/developerworks/library/x-javaxpathapi/index.html
Expand |
Embed | Plain Text
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); // never forget this! DocumentBuilder builder = domFactory.newDocumentBuilder(); XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); XPathExpression expr = xpath.compile("//node/@id"); NodeList nodes = (NodeList) result; for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); } }
You need to login to post a comment.
