public class ItsNatDOMUtil
extends java.lang.Object
Constructor and Description |
---|
ItsNatDOMUtil() |
Modifier and Type | Method and Description |
---|---|
static org.w3c.dom.Element |
createElement(java.lang.String tagName,
java.lang.String text,
org.w3c.dom.Document doc)
Creates a new DOM Element with the specified tag name containing a text node
with the specified text.
|
static org.w3c.dom.Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String text,
org.w3c.dom.Document doc)
Creates a new DOM Element with the specified namespace URI and qualified name containing a text node
with the specified text.
|
static org.w3c.dom.Node |
extractChildren(org.w3c.dom.Node parentNode)
Removes and returns the content of the specified node.
|
static org.w3c.dom.Element |
getElementById(java.lang.String id,
org.w3c.dom.Node container)
Returns the first element with the specified id attribute below or the same
as the specified node.
|
static java.lang.String |
getTextContent(org.w3c.dom.Element elem)
Returns the string content of the text node inside the specified Element.
|
static boolean |
isNodeInside(org.w3c.dom.Node node,
org.w3c.dom.Node parentNode)
Returns true if the provided
node is inside the specified parentNode . |
static void |
removeAllChildren(org.w3c.dom.Node parentNode)
Makes empty the specified node removing all child nodes.
|
static void |
setTextContent(org.w3c.dom.Element elem,
java.lang.String value)
Sets the string content of the text node inside the specified Element.
|
public static org.w3c.dom.Element getElementById(java.lang.String id, org.w3c.dom.Node container)
Use this method when several elements in the tree have the same id attribute
(duplicated id) because Document.getElementById(String)
returns the first one.
id
- the id attribute value to search.container
- the top most node to search below.public static org.w3c.dom.Element createElement(java.lang.String tagName, java.lang.String text, org.w3c.dom.Document doc)
tagName
- the tag name of the new element.text
- the string contained by the element as a text node, if null or empty no text node is added.doc
- the document owner of the new element.createElementNS(String,String,String,Document)
public static org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String text, org.w3c.dom.Document doc)
namespaceURI
- the namespace URI of the new element.qualifiedName
- the qualified name of the new element.text
- the string contained by the element as a text node, if null or empty no text node is added.doc
- the document owner of the new element.createElement(String,String,Document)
public static java.lang.String getTextContent(org.w3c.dom.Element elem)
If the element contains a child node different to a text node a cast exception is thrown.
elem
- the parent element.public static void setTextContent(org.w3c.dom.Element elem, java.lang.String value)
If the element already contains a text node, then is updated with the new value. If the new string value is null or empty the child text node is removed. If the first child node is different to a text node a cast exception is thrown.
elem
- the parent element.value
- the new string value of the text child node.public static org.w3c.dom.Node extractChildren(org.w3c.dom.Node parentNode)
If the node is empty returns null. If only contains a child node
returns this child node. If contains more than one child node returns
a DocumentFragment
with the child nodes.
parentNode
- the node to remove the content.DocumentFragment
.public static void removeAllChildren(org.w3c.dom.Node parentNode)
parentNode
- the node to remove the content.public static boolean isNodeInside(org.w3c.dom.Node node, org.w3c.dom.Node parentNode)
node
is inside the specified parentNode
.node
- the node to know whether inside parentNode subtree.parentNode
- the node to know whether it is an ancestor of node. If null the document associated to the node
parameter is used.node
is inside parentNode
.Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.