public class XmlUtils
extends java.lang.Object
Constructor and Description |
---|
XmlUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
docElementName(org.w3c.dom.Document document)
Returns the name of the document (root) element if it exists, or
null
if none can be found. |
static boolean |
doesAttributExist(org.w3c.dom.NamedNodeMap nodeMap,
java.lang.String attributeName)
Checks if a nodeName exist in a NamedNodeMap.
|
static boolean |
doesNodeExist(org.w3c.dom.NodeList nodeList,
java.lang.String nodeName)
Checks if a nodeName exist in a NodeList.
|
static org.w3c.dom.Node |
findFirstAttributeInList(org.w3c.dom.NamedNodeMap nodeMap,
java.lang.String attributeName)
Looks for a attribute in a NamedNodeMap, returns the first one if any is found.
|
static org.w3c.dom.Node |
findFirstNodeInList(org.w3c.dom.NodeList nodeList,
java.lang.String nodeName)
Looks for a node in a NodeList, returns the first one if any is found.
|
public static boolean doesNodeExist(org.w3c.dom.NodeList nodeList, java.lang.String nodeName)
nodeList
- the NodeList to check.nodeName
- the name to look up.public static org.w3c.dom.Node findFirstNodeInList(org.w3c.dom.NodeList nodeList, java.lang.String nodeName)
nodeList
- the NodeList to check.nodeName
- the nodeName to look up.public static org.w3c.dom.Node findFirstAttributeInList(org.w3c.dom.NamedNodeMap nodeMap, java.lang.String attributeName)
nodeMap
- attributeName
- public static boolean doesAttributExist(org.w3c.dom.NamedNodeMap nodeMap, java.lang.String attributeName)
nodeMap
- attributeName
- public static java.lang.String docElementName(org.w3c.dom.Document document)
null
if none can be found. This can be used to prevent NullPointerExceptions when
requesting document.getDocumentElement().getNodeName() directly.document
- XML documentnull
if input document
is null
or the document does not have a document element (eg empty doc)