Class XMLUtils


  • public class XMLUtils
    extends Object
    Author:
    Antoine Snyers (antoine at atmire.com), Kevin Van de Velde (kevin at atmire dot com), Ben Bosman (ben at atmire dot com), Mark Diggory (markd at atmire dot com)
    • Method Detail

      • getTextContent

        public static String getTextContent​(Node xml,
                                            String singleNodeXPath)
                                     throws XPathExpressionException
        Parameters:
        xml - The starting context (a Node or a Document, for example).
        singleNodeXPath - xpath
        Returns:
        node.getTextContent() on the node that matches singleNodeXPath null if nothing matches the NodeListXPath
        Throws:
        XPathExpressionException - if xpath error
      • getNode

        public static Node getNode​(Node xml,
                                   String nodeListXPath)
                            throws XPathExpressionException
        Parameters:
        xml - The starting context (a Node or a Document, for example).
        nodeListXPath - xpath
        Returns:
        A Node matches the NodeListXPath null if nothing matches the NodeListXPath
        Throws:
        XPathExpressionException - if xpath error
      • getNodeList

        public static NodeList getNodeList​(Node xml,
                                           String nodeListXPath)
                                    throws XPathExpressionException
        Parameters:
        xml - The starting context (a Node or a Document, for example).
        nodeListXPath - xpath
        Returns:
        A NodeList containing the nodes that match the NodeListXPath null if nothing matches the NodeListXPath
        Throws:
        XPathExpressionException - if xpath error
      • getNodeListIterator

        public static Iterator<Node> getNodeListIterator​(NodeList nodeList)
        Creates an iterator for all direct child nodes within a given NodeList that are element nodes: node.getNodeType() == Node.ELEMENT_NODE node instanceof Element
        Parameters:
        nodeList - NodeList
        Returns:
        iterator over nodes