DOM Class
Provides basic utilities to simplify loading and parsing xml
Constructors
There are no constructors. You can call the methods directly.
Methods
createDocument( java.net.URL url ) returns org.w3c.dom.Document
Used to create a DOM document from a URL.
createDocument( java.io.File file ) returns org.w3c.dom.Document
Used to create a DOM document from a java.io.File. Returns null if the
file cannot be serialized to XML.
createDocument( String xml ) returns org.w3c.dom.Document
Used to create a DOM document from a String. Returns null if the string
is invalid.
createDocument( java.io.InputStream is ) returns org.w3c.dom.Document
Used to create a DOM document from an InputStream.
createDocument( String xml, String charsetName ) returns org.w3c.dom.Document
equals( org.w3c.dom.Document xml, org.w3c.dom.Document xml2 ) returns boolean
Used to compare two XML documents by performing a raw string comparison.
escapeXml( String content ) returns String
Used to encode text data for use in an XML tag or attribute.
getAttributeValue( org.w3c.dom.NamedNodeMap attrCollection, String attrName ) returns String
Used to return the value of a given node attribute. The search is case
insensitive. If no match is found, returns an empty string.
getAttributeValue( org.w3c.dom.Node node, String attrName ) returns String
Used to return the value of a given node attribute. The search is case
insensitive. If no match is found, returns an empty string.
getDocumentAttributes( org.w3c.dom.Document xml ) returns org.w3c.dom.NamedNodeMap
xml | A org.w3c.dom.Document |
getElementsByTagName( String tagName, org.w3c.dom.Document xml ) returns org.w3c.dom.Node[]
Returns an array of nodes that match a given tagName (node name). The
results will include all nodes that match, regardless of namespace. To
narrow the results to a specific namespace, simply include the namespace
prefix in the tag name (e.g. "t:Contact").
getElementsByTagName( String tagName, org.w3c.dom.Node node ) returns org.w3c.dom.Node[]
Returns an array of nodes that match a given tagName (node name). The
results will include all nodes that match, regardless of namespace. To
narrow the results to a specific namespace, simply include the namespace
prefix in the tag name (e.g. "t:Contact"). Returns an empty array if
no nodes are found.
getNameSpaces( org.w3c.dom.Document xml ) returns java.util.HashMap
Returns a hashmap with all the namespaces found in a given xml document.
The hashmap key is the namespace prefix and the corresponding value is
the namespace url.
xml | A org.w3c.dom.Document |
getNodes( org.w3c.dom.NodeList nodeList ) returns org.w3c.dom.Node[]
Converts a NodeList into an array to simplify nested loops.
getNodeValue( org.w3c.dom.Node node ) returns String
Returns the value of a given node as text. If the node has children, the
method will return an xml fragment which will include the input node as
the outer node. This is a legacy feature which should be deprecated over
time.
getOuterNode( org.w3c.dom.Document xml ) returns org.w3c.dom.Node
Returns the outer node for a given xml document.
xml | A org.w3c.dom.Document |
getTargetNameSpace( org.w3c.dom.Document xml ) returns String
Returns the "targetNamespace" for a given xml document.
xml | A org.w3c.dom.Document |
getText( org.w3c.dom.Document xml ) returns String
Converts a DOM Document to a String
xml | A org.w3c.dom.Document |
getText( org.w3c.dom.NodeList nodeList ) returns String
Converts a NodeList to a String
getText( org.w3c.dom.Node node ) returns String
Converts a Node to a String
hasChildren( org.w3c.dom.Node node ) returns boolean
Used to determine whether a given node has any children. Differs from the
native DOM implementation in that this function only considers child
nodes that have a node type value equal to 1.
setAttributeValue( org.w3c.dom.Node node, String attrName, String attrValue ) returns void
Used to create or update an attribute.