asByteArray
public static byte[] asByteArray(Document doc,
String encoding)
throws TransformerException Convert the document to an array of bytes.
doc - The XML document.encoding - The encoding of the output data.
- The XML document as an array of bytes.
getElement
public static Element getElement(Element parent,
String elementName) Get the first instance of an element by name.
parent - The parent to get the element from.elementName - The name of the element to look for.
- The element or null if it is not found.
getIntValue
public static Integer getIntValue(Element parent,
String nodeName) Get the integer value of a subnode.
parent - The parent element that holds the values.nodeName - The name of the node that holds the integer value.
- The integer value of the node.
getStringValue
public static String getStringValue(Element node)
This will get the text value of an element.
node - The node to get the text value for.
getStringValue
public static String getStringValue(Element parent,
String nodeName) Get the value of a subnode.
parent - The parent element that holds the values.nodeName - The name of the node that holds the value.
- The value of the sub node.
newDocument
public static Document newDocument()
throws IOException Create a new blank XML document.
- The new blank XML document.
parse
public static Document parse(InputSource is)
throws IOException This will parse an InputSource and create a DOM document.
is - The stream to get the XML from.
parse
public static Document parse(InputStream is)
throws IOException This will parse an XML stream and create a DOM document.
is - The stream to get the XML from.
parse
public static Document parse(String fileName)
throws IOException This will parse an XML stream and create a DOM document.
fileName - The file to get the XML from.
save
public static void save(Document doc,
String file,
String encoding)
throws TransformerException Save the XML document to a file.
doc - The XML document to save.file - The file to save the document to.encoding - The encoding to save the file as.
save
public static void save(Node doc,
OutputStream outStream,
String encoding)
throws TransformerException Save the XML document to an output stream.
doc - The XML document to save.outStream - The stream to save the document to.encoding - The encoding to save the file as.
setElementableValue
public static void setElementableValue(Element parent,
String name,
Elementable node) Set an XML element document.
parent - The parent document to set the value in.name - The name of the XML element to set.node - The node to set or clear.
setIntValue
public static void setIntValue(Element parent,
String nodeName,
Integer intValue) Set the integer value of an element.
parent - The parent element that will hold this subelement.nodeName - The name of the subelement.intValue - The value to set.
setStringValue
public static void setStringValue(Element node,
String value) This will set the text value of an element.
node - The node to get the text value for.value - The new value to set the node to.
setStringValue
public static void setStringValue(Element parent,
String nodeName,
String nodeValue) Set the value of an element.
parent - The parent element that will hold this subelement.nodeName - The name of the subelement.nodeValue - The value to set.