Groovy Documentation

## groovy.xml
[Java] Class XmlUtil

    java.lang.Object
      groovy.xml.XmlUtil

    public class XmlUtil
    extends java.lang.Object

Used for pretty printing XML content.

Authors:
  Paul King

Method Summary
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, javax.xml.transform.Source... schemas)` Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with.
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, javax.xml.transform.Source... schemas)` Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with.
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, java.io.File schema)` Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against.
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, java.io.File schema)` Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against.
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, java.net.URL schema)` Factory method to create a SAXParser configured to validate according to a particular schema language and an URL pointing to the schema to validate against.
`static javax.xml.parsers.SAXParser` | `newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, java.net.URL schema)` Factory method to create a SAXParser configured to validate according to a particular schema language and an URL pointing to the schema to validate against.
`static java.lang.String` | `serialize(org.w3c.dom.Element element)` Return a pretty String version of the Element.
`static void` | `serialize(org.w3c.dom.Element element, java.io.OutputStream os)` Write a pretty version of the Element to the OutputStream.
`static void` | `serialize(org.w3c.dom.Element element, java.io.Writer w)` Write a pretty version of the Element to the Writer.
`static java.lang.String` | `serialize(Node node)` Return a pretty String version of the Node.
`static void` | `serialize(Node node, java.io.OutputStream os)` Write a pretty version of the Node to the OutputStream.
`static void` | `serialize(Node node, java.io.Writer w)` Write a pretty version of the Node to the Writer.
`static java.lang.String` | `serialize(GPathResult node)` Return a pretty version of the GPathResult.
`static void` | `serialize(GPathResult node, java.io.OutputStream os)` Write a pretty version of the GPathResult to the OutputStream.
`static void` | `serialize(GPathResult node, java.io.Writer w)` Write a pretty version of the GPathResult to the Writer.
`static java.lang.String` | `serialize(Writable writable)` Return a pretty String version of the XML content produced by the Writable.
`static void` | `serialize(Writable writable, java.io.OutputStream os)` Write a pretty version of the XML content produced by the Writable to the OutputStream.
`static void` | `serialize(Writable writable, java.io.Writer w)` Write a pretty version of the XML content produced by the Writable to the Writer.
`static java.lang.String` | `serialize(java.lang.String xmlString)` Return a pretty version of the XML content contained in the given String.
`static void` | `serialize(java.lang.String xmlString, java.io.OutputStream os)` Write a pretty version of the given XML string to the OutputStream.
`static void` | `serialize(java.lang.String xmlString, java.io.Writer w)` Write a pretty version of the given XML string to the Writer.

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, javax.xml.transform.Source... schemas)

  Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with. The created SAXParser will be namespace-aware and not validate against DTDs.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `schemas` - the schemas to validate against
  Returns:
    the created SAXParser
  See Also:
    newSAXParser(String, boolean, boolean, Source...)
  Since:
    1.8.7

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, javax.xml.transform.Source... schemas)

  Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `namespaceAware` - will the parser be namespace aware
    `validating` - will the parser also validate against DTDs
    `schemas` - the schemas to validate against
  Returns:
    the created SAXParser
  Since:
    1.8.7

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, java.io.File schema)

  Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against. The created SAXParser will be namespace-aware and not validate against DTDs.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `schema` - a file containing the schema to validate against
  Returns:
    the created SAXParser
  See Also:
    newSAXParser(String, boolean, boolean, File)
  Since:
    1.8.7

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, java.io.File schema)

  Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `namespaceAware` - will the parser be namespace aware
    `validating` - will the parser also validate against DTDs
    `schema` - a file containing the schema to validate against
  Returns:
    the created SAXParser
  Since:
    1.8.7

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, java.net.URL schema)

  Factory method to create a SAXParser configured to validate according to a particular schema language and an URL pointing to the schema to validate against. The created SAXParser will be namespace-aware and not validate against DTDs.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `schema` - a URL pointing to the schema to validate against
  Returns:
    the created SAXParser
  See Also:
    newSAXParser(String, boolean, boolean, URL)
  Since:
    1.8.7

### newSAXParser

    public static javax.xml.parsers.SAXParser newSAXParser(java.lang.String schemaLanguage, boolean namespaceAware, boolean validating, java.net.URL schema)

  Factory method to create a SAXParser configured to validate according to a particular schema language and an URL pointing to the schema to validate against.
  throws:
    SAXException
  throws:
    ParserConfigurationException
  Parameters:
    `schemaLanguage` - the schema language used, e.g. XML Schema or RelaxNG (as per the String representation in javax.xml.XMLConstants)
    `namespaceAware` - will the parser be namespace aware
    `validating` - will the parser also validate against DTDs
    `schema` - a URL pointing to the schema to validate against
  Returns:
    the created SAXParser
  Since:
    1.8.7

### serialize

    public static java.lang.String serialize(org.w3c.dom.Element element)

  Return a pretty String version of the Element.
  Parameters:
    `element` - the Element to serialize
  Returns:
    the pretty String representation of the Element

### serialize

    public static void serialize(org.w3c.dom.Element element, java.io.OutputStream os)

  Write a pretty version of the Element to the OutputStream.
  Parameters:
    `element` - the Element to serialize
    `os` - the OutputStream to write to

### serialize

    public static void serialize(org.w3c.dom.Element element, java.io.Writer w)

  Write a pretty version of the Element to the Writer.
  Parameters:
    `element` - the Element to serialize
    `w` - the Writer to write to

### serialize

    public static java.lang.String serialize(Node node)

  Return a pretty String version of the Node.
  Parameters:
    `node` - the Node to serialize
  Returns:
    the pretty String representation of the Node

### serialize

    public static void serialize(Node node, java.io.OutputStream os)

  Write a pretty version of the Node to the OutputStream.
  Parameters:
    `node` - the Node to serialize
    `os` - the OutputStream to write to

### serialize

    public static void serialize(Node node, java.io.Writer w)

  Write a pretty version of the Node to the Writer.
  Parameters:
    `node` - the Node to serialize
    `w` - the Writer to write to

### serialize

    public static java.lang.String serialize(GPathResult node)

  Return a pretty version of the GPathResult.
  Parameters:
    `node` - a GPathResult to serialize to a String
  Returns:
    the pretty String representation of the GPathResult

### serialize

    public static void serialize(GPathResult node, java.io.OutputStream os)

  Write a pretty version of the GPathResult to the OutputStream.
  Parameters:
    `node` - a GPathResult to serialize
    `os` - the OutputStream to write to

### serialize

    public static void serialize(GPathResult node, java.io.Writer w)

  Write a pretty version of the GPathResult to the Writer.
  Parameters:
    `node` - a GPathResult to serialize
    `w` - the Writer to write to

### serialize

    public static java.lang.String serialize(Writable writable)

  Return a pretty String version of the XML content produced by the Writable.
  Parameters:
    `writable` - the Writable to serialize
  Returns:
    the pretty String representation of the content from the Writable

### serialize

    public static void serialize(Writable writable, java.io.OutputStream os)

  Write a pretty version of the XML content produced by the Writable to the OutputStream.
  Parameters:
    `writable` - the Writable to serialize
    `os` - the OutputStream to write to

### serialize

    public static void serialize(Writable writable, java.io.Writer w)

  Write a pretty version of the XML content produced by the Writable to the Writer.
  Parameters:
    `writable` - the Writable to serialize
    `w` - the Writer to write to

### serialize

    public static java.lang.String serialize(java.lang.String xmlString)

  Return a pretty version of the XML content contained in the given String.
  Parameters:
    `xmlString` - the String to serialize
  Returns:
    the pretty String representation of the original content

### serialize

    public static void serialize(java.lang.String xmlString, java.io.OutputStream os)

  Write a pretty version of the given XML string to the OutputStream.
  Parameters:
    `xmlString` - the String to serialize
    `os` - the OutputStream to write to

### serialize

    public static void serialize(java.lang.String xmlString, java.io.Writer w)

  Write a pretty version of the given XML string to the Writer.
  Parameters:
    `xmlString` - the String to serialize
    `w` - the Writer to write to

Groovy Documentation