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 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 of the XHTML.
      Parameters:
      doc - Dom tree
      Returns:
      String containing only the text from the provided Dom tree.