Package org.apache.wiki.util
Class XmlUtil
java.lang.Object
org.apache.wiki.util.XmlUtil
Utility class to parse XML files.
This uses JDOM2 as its backing implementation.
- Since:
- 2.10
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
extractTextFromDocument
(org.jdom2.Document doc) Renders all the text() nodes from the DOM tree.static org.jdom2.Element
getXPathElement
(org.jdom2.Element base, String expression) static List<org.jdom2.Element>
parse
(InputStream xmlStream, String requestedNodes) Parses the given stream and returns the requested nodes.static List<org.jdom2.Element>
Parses the given XML file and returns the requested nodes.
-
Method Details
-
parse
Parses the given XML file and returns the requested nodes. If there's an error accessing or parsing the file, an empty list is returned.- Parameters:
xml
- file to parse; matches all resources from classpath, filters repeated items.requestedNodes
- requested nodes on the xml file- Returns:
- the requested nodes of the XML file.
-
parse
Parses the given stream and returns the requested nodes. If there's an error accessing or parsing the stream, an empty list is returned.- Parameters:
xmlStream
- stream to parse.requestedNodes
- requestd nodes on the xml stream.- Returns:
- the requested nodes of the XML stream.
-
extractTextFromDocument
Renders all the text() nodes from the DOM tree. This is very useful for cleaning away all the XHTML.- Parameters:
doc
- Dom tree- Returns:
- String containing only the text from the provided Dom tree.
-
getXPathElement
-