Package org.apache.wiki.util
Class XmlUtil
- java.lang.Object
-
- org.apache.wiki.util.XmlUtil
-
public final class XmlUtil extends java.lang.Object
Utility class to parse XML files.This uses JDOM2 as its backing implementation.
- Since:
- 2.10
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringextractTextFromDocument(org.jdom2.Document doc)Renders all the text() nodes from the DOM tree.static org.jdom2.ElementgetXPathElement(org.jdom2.Element base, java.lang.String expression)static java.util.List<org.jdom2.Element>parse(java.io.InputStream xmlStream, java.lang.String requestedNodes)Parses the given stream and returns the requested nodes.static java.util.List<org.jdom2.Element>parse(java.lang.String xml, java.lang.String requestedNodes)Parses the given XML file and returns the requested nodes.
-
-
-
Method Detail
-
parse
public static java.util.List<org.jdom2.Element> parse(java.lang.String xml, java.lang.String requestedNodes)
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
public static java.util.List<org.jdom2.Element> parse(java.io.InputStream xmlStream, java.lang.String requestedNodes)
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
public static java.lang.String extractTextFromDocument(org.jdom2.Document doc)
Renders all the text() nodes from the DOM tree. This is very useful for cleaning away all of the XHTML.- Parameters:
doc- Dom tree- Returns:
- String containing only the text from the provided Dom tree.
-
getXPathElement
public static org.jdom2.Element getXPathElement(org.jdom2.Element base, java.lang.String expression)
-
-