public class XMLUtils
extends java.lang.Object
Constructor and Description |
---|
XMLUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addChild(org.w3c.dom.Node parent,
org.w3c.dom.Node child) |
static void |
addText(org.w3c.dom.Document doc,
org.w3c.dom.Node parent,
java.lang.String data) |
static org.w3c.dom.Document |
createDocumentNode() |
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document doc,
java.lang.String tagName) |
static org.w3c.dom.Document |
createXML(byte[] xml) |
static org.w3c.dom.Document |
createXML(java.lang.String xml) |
static java.lang.String |
escapeXML(java.lang.String input) |
static java.lang.String |
getAttribute(org.w3c.dom.Document doc,
java.lang.String tagName,
java.lang.String attribute) |
static void |
insertLeadingPI(org.w3c.dom.Document doc,
java.lang.String target,
java.lang.String data) |
static void |
insertTrailingPI(org.w3c.dom.Document doc,
java.lang.String target,
java.lang.String data) |
static void |
printNode(org.w3c.dom.Node node,
java.lang.String increment) |
static java.lang.String |
removeAttribute(org.w3c.dom.Document doc,
java.lang.String tagName,
java.lang.String attribute) |
static byte[] |
serializeToByteArray(org.w3c.dom.Document doc) |
static java.lang.String |
serializeToString(org.w3c.dom.Document doc) |
static java.lang.String |
serializeToString(org.w3c.dom.Node node,
java.lang.String encoding)
Serialize XML Document to string using Transformer
|
static java.lang.String |
serializeToStringLS(org.w3c.dom.Document doc)
Serialize XML Document to string using DOM Level 3 Load/Save
|
static java.lang.String |
serializeToStringLS(org.w3c.dom.Document doc,
org.w3c.dom.Node node)
Serialize XML Document to string using DOM Level 3 Load/Save
|
static java.lang.String |
serializeToStringLS(org.w3c.dom.Document doc,
org.w3c.dom.Node node,
java.lang.String encoding)
Serialize XML Node to string
|
static void |
showXML(org.w3c.dom.Document document) |
public static void addChild(org.w3c.dom.Node parent, org.w3c.dom.Node child)
public static void addText(org.w3c.dom.Document doc, org.w3c.dom.Node parent, java.lang.String data)
public static org.w3c.dom.Document createDocumentNode()
public static org.w3c.dom.Element createElement(org.w3c.dom.Document doc, java.lang.String tagName)
public static org.w3c.dom.Document createXML(byte[] xml)
public static org.w3c.dom.Document createXML(java.lang.String xml)
public static java.lang.String escapeXML(java.lang.String input)
public static java.lang.String getAttribute(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)
public static void insertLeadingPI(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)
public static void insertTrailingPI(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)
public static void printNode(org.w3c.dom.Node node, java.lang.String increment)
public static java.lang.String removeAttribute(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)
public static byte[] serializeToByteArray(org.w3c.dom.Document doc) throws java.io.IOException
java.io.IOException
public static java.lang.String serializeToStringLS(org.w3c.dom.Document doc) throws java.io.IOException
doc
- XML Documentjava.io.IOException
public static java.lang.String serializeToStringLS(org.w3c.dom.Document doc, org.w3c.dom.Node node) throws java.io.IOException
doc
- XML Documentnode
- the Node to serializejava.io.IOException
public static java.lang.String serializeToStringLS(org.w3c.dom.Document doc, org.w3c.dom.Node node, java.lang.String encoding) throws java.io.IOException
Note: this method is supposed to be faster than the Transform version but the output control is limited. If node is Document node, it will output XML PI which sometimes we want to avoid.
doc
- XML documentnode
- Node to be serializedencoding
- encoding for the outputjava.io.IOException
public static java.lang.String serializeToString(org.w3c.dom.Document doc) throws java.io.IOException
java.io.IOException
public static java.lang.String serializeToString(org.w3c.dom.Node node, java.lang.String encoding) throws java.io.IOException
node
- the XML node (and the subtree rooted at this node) to be serializedencoding
- encoding for the XML documentjava.io.IOException
public static void showXML(org.w3c.dom.Document document)