java.lang.Object
samples.addr.DOMUtils
- public class DOMUtils
- extends java.lang.Object
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NS_URI_XMLNS
private static java.lang.String NS_URI_XMLNS
- The namespaceURI represented by the prefix
xmlns.
DOMUtils
public DOMUtils()
getAttribute
public static java.lang.String getAttribute(org.w3c.dom.Element el,
java.lang.String attrName)
- Returns the value of an attribute of an element. Returns null
if the attribute is not found (whereas Element.getAttribute
returns "" if an attrib is not found).
getAttributeNS
public static java.lang.String getAttributeNS(org.w3c.dom.Element el,
java.lang.String namespaceURI,
java.lang.String localPart)
- Returns the value of an attribute of an element. Returns null
if the attribute is not found (whereas Element.getAttributeNS
returns "" if an attrib is not found).
getChildCharacterData
public static java.lang.String getChildCharacterData(org.w3c.dom.Element parentEl)
- Concat all the text and cdata node children of this elem and return
the resulting text.
getFirstChildElement
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element elem)
- Return the first child element of the given element. Null if no
children are found.
getNextSiblingElement
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element elem)
- Return the next sibling element of the given element. Null if no
more sibling elements are found.
findChildElementWithAttribute
public static org.w3c.dom.Element findChildElementWithAttribute(org.w3c.dom.Element elem,
java.lang.String attrName,
java.lang.String attrValue)
- Return the first child element of the given element which has the
given attribute with the given value.
countKids
public static int countKids(org.w3c.dom.Element elem,
short nodeType)
- Count number of children of a certain type of the given element.
getNamespaceURIFromPrefix
public static java.lang.String getNamespaceURIFromPrefix(org.w3c.dom.Node context,
java.lang.String prefix)
- Given a prefix and a node, return the namespace URI that the prefix
has been associated with. This method is useful in resolving the
namespace URI of attribute values which are being interpreted as
QNames. If prefix is null, this method will return the default
namespace.
getElementByID
public static org.w3c.dom.Element getElementByID(org.w3c.dom.Element el,
java.lang.String id)