Created
December 6, 2013 14:29
-
-
Save deckerego/7825615 to your computer and use it in GitHub Desktop.
Search an XML Document with dom4j
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File file = new File("/path/to/file"); | |
SAXReader reader = new SAXReader(); | |
Document document = reader.read(file); | |
XPath pathSelector = DocumentHelper.createXPath("/root/childOne/leaf[@attributeName='attributeValue']"); | |
List pathNodes = pathSelector.selectNodes(document); | |
for(Object pathNode : pathNodes) { | |
Element pathElement = (Element) pathNode; | |
System.out.println(pathElement.getTextTrim()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment