Class XmlUtils


  • public class XmlUtils
    extends Object
    Author:
    Sumer Jabri, Alfonso Vásquez
    • Constructor Detail

      • XmlUtils

        public XmlUtils()
    • Method Detail

      • selectObject

        public static Object selectObject​(org.dom4j.Node node,
                                          String xpathQuery)
        Executes an XPath query to retrieve an object. Normally, if the XPath result doesn't have a result, an empty collection is returned. This object checks that case and returns null accordingly.
      • selectSingleNodeValue

        public static String selectSingleNodeValue​(org.dom4j.Node node,
                                                   String xpathQuery)
        Executes the specified XPath query as a single node query, returning the text value of the resulting single node.
      • selectSingleNodeValue

        public static String selectSingleNodeValue​(org.dom4j.Node node,
                                                   String xpathQuery,
                                                   Map<String,​String> namespaceUris)
        Executes the specified namespace aware XPath query as a single node query, returning the text value of the resulting single node.
      • selectNodeValues

        public static List<String> selectNodeValues​(org.dom4j.Node node,
                                                    String xpathQuery)
        Executes the specified XPath query as a multiple node query, returning the text values of the resulting list of nodes.
      • selectNodeValues

        public static List<String> selectNodeValues​(org.dom4j.Node node,
                                                    String xpathQuery,
                                                    Map<String,​String> namespaceUris)
        Executes the specified namespace aware XPath query as a multiple node query, returning the text values of the resulting list of nodes.
      • selectSingleNode

        public static org.dom4j.Node selectSingleNode​(org.dom4j.Node node,
                                                      String xpathQuery,
                                                      Map<String,​String> namespaceUris)
        Executes the specified namespace aware XPath query as a single node query, returning the resulting single node.
      • selectNodes

        public static List<org.dom4j.Node> selectNodes​(org.dom4j.Node node,
                                                       String xpathQuery,
                                                       Map<String,​String> namespaceUris)
        Executes the specified namespace aware XPath query as a multiple node query, returning the resulting list of nodes.
      • documentToPrettyString

        public static String documentToPrettyString​(org.dom4j.Document document)
        Returns the given document as a XML string in a "pretty" format.
        Parameters:
        document -
        Returns:
        the document as an XML string