Package org.apache.wiki.util

# Class XmlUtil

java.lang.Object
org.apache.wiki.util.XmlUtil

public final class XmlUtil extends Object
Utility class to parse XML files.

This uses JDOM2 as its backing implementation.

Since:
  2.10

## Method Summary

Modifier and Type
Method
Description
`static 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>`
`parse(String xml, String requestedNodes)`
Parses the given XML file and returns the requested nodes.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### parse

public static List<org.jdom2.Element> parse(String xml, 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 List<org.jdom2.Element> parse(InputStream xmlStream, 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 String extractTextFromDocument(org.jdom2.Document doc)
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

public static org.jdom2.Element getXPathElement(org.jdom2.Element base, String expression)