Class DOMUtils

java.lang.Object
com.peterphi.std.util.DOMUtils

public class DOMUtils extends Object
  • Method Details

    • createDocumentBuilder

      public static DocumentBuilder createDocumentBuilder()
      Create a new (namespace-aware) DocumentBuilder
      Returns:
    • parse

      public static Document parse(File file)
    • parse

      public static Document parse(String xml)
    • parse

      public static Document parse(InputStream xml)
    • parse

      public static Document parse(Reader xml)
    • parse

      public static Document parse(InputSource src)
    • serialise

      public static String serialise(Node n)
    • serialiseBytes

      public static byte[] serialiseBytes(Node n)
    • serialise

      public static void serialise(Node n, StreamResult result)
    • serialise

      public static void serialise(Node n, OutputStream os)
    • serialise

      public static void serialise(Node n, Writer writer)
    • serialise

      public static void serialise(Node n, File file)
    • pretty

      public static String pretty(Node source)
      Serialise the provided Node to a pretty-printed String with the default indent settings
      N.B. this method also trims any leading/trailing whitespace from TEXT nodes
      Parameters:
      source - the input Node
      Returns:
    • pretty

      public static String pretty(Source source)
      Serialise the provided source to a pretty-printed String with the default indent settings
      Parameters:
      source - the input Source
    • trim

      public static Node trim(Element e)
      Trim all TEXT Nodes under the provided Element
      Parameters:
      e -
      Returns:
    • pretty

      public static void pretty(Source input, StreamResult output)
      Serialise the provided source to the provided destination, pretty-printing with the default indent settings
      Parameters:
      input - the source
      output - the destination