public final class XMLUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
document2String(org.w3c.dom.Document doc)
Returns the string representation of a given XML document.
|
static java.lang.String |
getNodeValue(java.lang.String tag,
java.lang.StringBuilder doc)
Gets the value of the node.
|
static java.lang.String |
getRootTag(java.lang.StringBuilder strXml)
Searches a XML document root tag value given the document as a string.
|
static java.lang.StringBuilder |
prettyPrint(java.lang.String whatToPretty)
Gets a pretty print document using the format of the opening and closing tags.
|
static java.lang.StringBuilder |
removeNameSpaces(java.lang.String xml)
This method removes namespace prefixes of a given document with leaving this default namespace.
|
static java.lang.String |
soapMessage2String(javax.xml.soap.SOAPMessage message)
Transforms a SOAP message into a String.
|
static org.w3c.dom.Document |
string2Document(java.lang.String msgAsString)
Returns an XML document from a String.
|
static org.w3c.dom.Document |
string2Document(java.lang.StringBuilder msgAsString)
Returns an XML document from a StringBuilder (String).
|
public static java.lang.String getNodeValue(java.lang.String tag,
java.lang.StringBuilder doc)
tag - Tag name.doc - XML document in string.public static org.w3c.dom.Document string2Document(java.lang.String msgAsString)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
msgAsString - String that contains an XML document to be transformed.javax.xml.parsers.ParserConfigurationException - If the factory cannot transform the the string into a document.org.xml.sax.SAXException - If the given string doesn't contain a valid XML document.java.io.IOException - If the given string cannot be read.public static org.w3c.dom.Document string2Document(java.lang.StringBuilder msgAsString)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
msgAsString - String that contains an XML document to be transformed.javax.xml.parsers.ParserConfigurationException - If the factory cannot transform the the string into a document.org.xml.sax.SAXException - If the given string doesn't contain a valid XML document.java.io.IOException - If the given string cannot be read.public static java.lang.String document2String(org.w3c.dom.Document doc)
throws javax.xml.transform.TransformerException
doc - The input document to transform.javax.xml.transform.TransformerException - If it's impossible to convert the given document.public static java.lang.StringBuilder prettyPrint(java.lang.String whatToPretty)
whatToPretty - Text formatting.public static java.lang.StringBuilder removeNameSpaces(java.lang.String xml)
...
output
...
xml - XML document to remove references to prefixes of namespaces.public static java.lang.String getRootTag(java.lang.StringBuilder strXml)
strXml - document as a string.null if the given xml is not well formed (cannot find root tag).public static java.lang.String soapMessage2String(javax.xml.soap.SOAPMessage message)
throws javax.xml.soap.SOAPException
message - SOAP message.javax.xml.soap.SOAPException - Exception transform the message.