org.littleshoot.util.xml
Class XmlUtils

java.lang.Object
  extended by org.littleshoot.util.xml.XmlUtils

public final class XmlUtils
extends Object

XML utilities class.


Field Summary
static NodeList EMPTY_NODE_LIST
          Empty list of XML nodes.
 
Constructor Summary
XmlUtils()
           
 
Method Summary
static void printDoc(Document doc)
          Prints the XML Document to standard out with handy indentation.
static void printDoc(String xml)
           
static void replaceNodeValue(Document doc, String xPath, String newValue)
          Replaces the text value of a node in a document with the specified value using XPath.
static Document toDoc(InputStream is)
           
static Document toDoc(InputStream is, String endStatementTag)
           
static Document toDoc(String str)
           
static String toString(Document doc)
          Returns the XML Document as a readable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_NODE_LIST

public static final NodeList EMPTY_NODE_LIST
Empty list of XML nodes.

Constructor Detail

XmlUtils

public XmlUtils()
Method Detail

replaceNodeValue

public static void replaceNodeValue(Document doc,
                                    String xPath,
                                    String newValue)
Replaces the text value of a node in a document with the specified value using XPath.

Parameters:
doc - The document to modify.
xPath - The XPath string to locate the node to modify. This should point to the Node containing a Text node as its first child.
newValue - The new text value to place in the node.

printDoc

public static void printDoc(Document doc)
Prints the XML Document to standard out with handy indentation.

Parameters:
doc - The Document to print.

toString

public static String toString(Document doc)
Returns the XML Document as a readable string.

Parameters:
doc - The Document to convert to a string.
Returns:
The returned String.

toDoc

public static Document toDoc(String str)
                      throws IOException,
                             SAXException
Throws:
IOException
SAXException

toDoc

public static Document toDoc(InputStream is)
                      throws IOException,
                             SAXException
Throws:
IOException
SAXException

toDoc

public static Document toDoc(InputStream is,
                             String endStatementTag)
                      throws IOException,
                             SAXException
Throws:
IOException
SAXException

printDoc

public static void printDoc(String xml)


Copyright © 2011-2013 LittleShoot. All Rights Reserved.