Class XMLUtils


  • public class XMLUtils
    extends Object
    Common methods for working with XML.
    Since:
    2.5.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    • Method Detail

      • transformerFactory

        public static TransformerFactory transformerFactory()
        Obtain a new instance of a TransformerFactory which is considered to be secure against XXE (XML External Entity) attacks.

        For safety, the use of all protocols by external entities is disabled.

        Returns:
        a new, secure TransformerFactory
      • toString

        public static String toString​(NodeList nodeList)
        Returns a string representation of the specified XML NodeList.
        Parameters:
        nodeList - the NodeList to be converted
        Returns:
        the node list as string
        Throws:
        ConfigurationException - if unable to convert a document node into string
      • toString

        public static String toString​(Node node)
        Returns a string representation of the specified XML Node.

        If the XML node is either an attribute or a text node, the text content will be returned. For all other node types (e.g.: document, or element), the node will be transformed/encoded as string.

        Parameters:
        node - the Node to be converted
        Returns:
        the node value as string
        Throws:
        ConfigurationException - if unable to convert the document node into string