public class XMLUtils
extends java.lang.Object
| Constructor and Description |
|---|
XMLUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.w3c.dom.Element |
createLastPathComponent(org.w3c.dom.Document doc,
java.lang.String[] path)
Creates (only if necessary) and returns the element which is at the end of the specified
path.
|
static java.lang.String |
getAttributeByName(org.w3c.dom.Node node,
java.lang.String name)
Get the attribute with given name's value
|
static org.w3c.dom.Element |
getChildElementByChain(org.w3c.dom.Element element,
java.lang.String[] chain,
boolean create)
Returns the element which is at the end of the specified chain
|
static org.w3c.dom.Element |
getChildElementByTagName(org.w3c.dom.Element parent,
java.lang.String tagName)
Returns the child element with the specified tagName for the specified parent element
|
static org.w3c.dom.Element |
getChildElementByTagNameNS(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String nsName) |
static java.util.List<org.w3c.dom.Element> |
getChildElementsByTagName(org.w3c.dom.Element parent,
java.lang.String tagName) |
static java.util.List<org.w3c.dom.Element> |
getChildElementsByTagNameNS(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String nsName) |
static org.w3c.dom.CDATASection |
getElementCDataNode(org.w3c.dom.Element element)
Returns element's CDATA Node
|
static java.lang.String |
getElementCDataValue(org.w3c.dom.Element e)
Gets CDATA value of an element
|
static org.w3c.dom.Text |
getElementTextNode(org.w3c.dom.Element element)
Returns element's TEXT Node
|
static java.lang.String |
getElementTextValueDeprecated(org.w3c.dom.Element parentNode)
Get the data of the element , no matter whether it is TXT ot CDATA
|
static boolean |
isXMLFormat(byte[] document)
Method that indicates whether a document is XML (true) or not (false).
|
static void |
printChildElements(org.w3c.dom.Element parent,
java.io.PrintStream out,
boolean deep,
java.lang.String prefix)
Used for debuging
|
static void |
setElementCDataValue(org.w3c.dom.Element e,
java.lang.String data)
Sets element CDATA data
|
static void |
setElementTextValue(org.w3c.dom.Element e,
java.lang.String data)
Sets element TEXT data
|
static void |
writeXML(java.io.File file,
org.w3c.dom.Node node) |
static void |
writeXML(java.io.OutputStream outStream,
org.w3c.dom.Node node) |
static void |
writeXML(java.io.OutputStream outStream,
org.w3c.dom.Node node,
boolean indent) |
static void |
writeXML(java.io.Writer writer,
org.w3c.dom.Document document,
java.lang.String doctypeSystem,
java.lang.String doctypePublic) |
static void |
writeXML(java.io.Writer writer,
org.w3c.dom.Node node,
boolean indent)
Writes the specified document to the given file.
|
public static java.lang.String getAttributeByName(org.w3c.dom.Node node,
java.lang.String name)
node - the node which attribute's value is returnedname - name of the attributepublic static java.lang.String getElementTextValueDeprecated(org.w3c.dom.Element parentNode)
parentNode - the node which data is returnedpublic static void setElementTextValue(org.w3c.dom.Element e,
java.lang.String data)
e - the elementdata - the new datapublic static void setElementCDataValue(org.w3c.dom.Element e,
java.lang.String data)
e - the lementdata - the new datapublic static java.lang.String getElementCDataValue(org.w3c.dom.Element e)
e - the elementpublic static org.w3c.dom.CDATASection getElementCDataNode(org.w3c.dom.Element element)
element - the element which CDATA node is returnedpublic static org.w3c.dom.Text getElementTextNode(org.w3c.dom.Element element)
element - the element which TEXT node is returnedpublic static void writeXML(java.io.File file,
org.w3c.dom.Node node)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static void writeXML(java.io.OutputStream outStream,
org.w3c.dom.Node node)
public static void writeXML(java.io.OutputStream outStream,
org.w3c.dom.Node node,
boolean indent)
public static void writeXML(java.io.Writer writer,
org.w3c.dom.Node node,
boolean indent)
out - the output Filedocument - the document to be writenpublic static void writeXML(java.io.Writer writer,
org.w3c.dom.Document document,
java.lang.String doctypeSystem,
java.lang.String doctypePublic)
public static org.w3c.dom.Element getChildElementByChain(org.w3c.dom.Element element,
java.lang.String[] chain,
boolean create)
element - chain - public static org.w3c.dom.Element createLastPathComponent(org.w3c.dom.Document doc,
java.lang.String[] path)
doc - the target document where the specified path should be createdpath - a dot separated string indicating the path to be createdpublic static org.w3c.dom.Element getChildElementByTagNameNS(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String nsName)
public static org.w3c.dom.Element getChildElementByTagName(org.w3c.dom.Element parent,
java.lang.String tagName)
parent - tagName - public static java.util.List<org.w3c.dom.Element> getChildElementsByTagNameNS(org.w3c.dom.Element parent,
java.lang.String tagName,
java.lang.String nsName)
public static java.util.List<org.w3c.dom.Element> getChildElementsByTagName(org.w3c.dom.Element parent,
java.lang.String tagName)
public static void printChildElements(org.w3c.dom.Element parent,
java.io.PrintStream out,
boolean deep,
java.lang.String prefix)
parent - Elementout - PrintStreamdeep - booleanprefix - Stringpublic static boolean isXMLFormat(byte[] document)
document -