jodd.util
Class XmlUtil

java.lang.Object
  extended by jodd.util.XmlUtil

public class XmlUtil
extends java.lang.Object

Some XML and XPath utilities.


Constructor Summary
XmlUtil()
           
 
Method Summary
static java.util.List filterNodeList(org.w3c.dom.NodeList nodeList, short keepNodeType)
          Filters node list by keeping nodes of specified type.
static java.util.List<org.w3c.dom.Node> filterNodeList(org.w3c.dom.NodeList nodeList, short keepNodeType, java.lang.String nodeName)
          Filters node list by keeping nodes of specified type and node name.
static java.util.List filterNodeListElements(org.w3c.dom.NodeList nodeList)
          Filter node list for all Element nodes.
static java.util.List<org.w3c.dom.Node> filterNodeListElements(org.w3c.dom.NodeList nodeList, java.lang.String nodeName)
          Filter node list for Element nodes of specified name.
static java.util.Map<java.lang.String,java.lang.String> getAllAttributes(org.w3c.dom.Node node)
          Returns a map of all node's attributes.
static java.lang.String getAttributeValue(org.w3c.dom.Element element, java.lang.String name)
          Get element's attribute value or null if attribute not found or empty.
static java.lang.String getAttributeValue(org.w3c.dom.Node node, java.lang.String attrName)
          Returns attribute value of a node or null if attribute name not found.
static java.util.List getChildElements(org.w3c.dom.Node node)
          Returns a list of all child Elements,
static java.util.List getChildElements(org.w3c.dom.Node node, java.lang.String nodeName)
          Returns a list of child Elements of specified name.
static java.lang.String getChildTextNodeValue(org.w3c.dom.Node node)
          Returns value of single child text node or null.
static java.lang.String getFirstChildTextNodeValue(org.w3c.dom.Node node)
          Returns value of first available child text node or null if not found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlUtil

public XmlUtil()
Method Detail

getAllAttributes

public static java.util.Map<java.lang.String,java.lang.String> getAllAttributes(org.w3c.dom.Node node)
Returns a map of all node's attributes. All non-attribute nodes are ignored.


getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Node node,
                                                 java.lang.String attrName)
Returns attribute value of a node or null if attribute name not found. Specified attribute is searched on every call. Consider getAllAttributes(org.w3c.dom.Node) for better performances.


getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Element element,
                                                 java.lang.String name)
Get element's attribute value or null if attribute not found or empty.


filterNodeList

public static java.util.List filterNodeList(org.w3c.dom.NodeList nodeList,
                                            short keepNodeType)
Filters node list by keeping nodes of specified type.


filterNodeList

public static java.util.List<org.w3c.dom.Node> filterNodeList(org.w3c.dom.NodeList nodeList,
                                                              short keepNodeType,
                                                              java.lang.String nodeName)
Filters node list by keeping nodes of specified type and node name.


filterNodeListElements

public static java.util.List filterNodeListElements(org.w3c.dom.NodeList nodeList)
Filter node list for all Element nodes.


filterNodeListElements

public static java.util.List<org.w3c.dom.Node> filterNodeListElements(org.w3c.dom.NodeList nodeList,
                                                                      java.lang.String nodeName)
Filter node list for Element nodes of specified name.


getChildElements

public static java.util.List getChildElements(org.w3c.dom.Node node)
Returns a list of all child Elements,


getChildElements

public static java.util.List getChildElements(org.w3c.dom.Node node,
                                              java.lang.String nodeName)
Returns a list of child Elements of specified name.


getFirstChildTextNodeValue

public static java.lang.String getFirstChildTextNodeValue(org.w3c.dom.Node node)
Returns value of first available child text node or null if not found.


getChildTextNodeValue

public static java.lang.String getChildTextNodeValue(org.w3c.dom.Node node)
Returns value of single child text node or null.



Copyright ©2008 Jodd Team