Package pixy.string

Class XMLUtils

java.lang.Object
pixy.string.XMLUtils

public class XMLUtils
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    XMLUtils()  
  • Method Summary

    Modifier and Type Method Description
    static void addChild​(org.w3c.dom.Node parent, org.w3c.dom.Node child)  
    static void addText​(org.w3c.dom.Document doc, org.w3c.dom.Node parent, java.lang.String data)  
    static org.w3c.dom.Document createDocumentNode()  
    static org.w3c.dom.Node createElement​(org.w3c.dom.Document doc, java.lang.String tagName)  
    static org.w3c.dom.Document createXML​(byte[] xml)  
    static org.w3c.dom.Document createXML​(java.lang.String xml)  
    static java.lang.String escapeXML​(java.lang.String input)  
    static java.lang.String getAttribute​(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)  
    static void insertLeadingPI​(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)  
    static void insertTrailingPI​(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)  
    static void printNode​(org.w3c.dom.Node node, java.lang.String indent)  
    static java.lang.String removeAttribute​(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)  
    static byte[] serializeToByteArray​(org.w3c.dom.Document doc)  
    static java.lang.String serializeToString​(org.w3c.dom.Document doc)  
    static java.lang.String serializeToString​(org.w3c.dom.Node node, java.lang.String encoding)
    Serialize XML Document to string using Transformer
    static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc)
    Serialize XML Document to string using DOM Level 3 Load/Save
    static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc, org.w3c.dom.Node node)
    Serialize XML Document to string using DOM Level 3 Load/Save
    static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc, org.w3c.dom.Node node, java.lang.String encoding)
    Serialize XML Node to string
    static void showXML​(org.w3c.dom.Document document)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • addChild

      public static void addChild​(org.w3c.dom.Node parent, org.w3c.dom.Node child)
    • addText

      public static void addText​(org.w3c.dom.Document doc, org.w3c.dom.Node parent, java.lang.String data)
    • createDocumentNode

      public static org.w3c.dom.Document createDocumentNode()
    • createElement

      public static org.w3c.dom.Node createElement​(org.w3c.dom.Document doc, java.lang.String tagName)
    • createXML

      public static org.w3c.dom.Document createXML​(byte[] xml)
    • createXML

      public static org.w3c.dom.Document createXML​(java.lang.String xml)
    • escapeXML

      public static java.lang.String escapeXML​(java.lang.String input)
    • getAttribute

      public static java.lang.String getAttribute​(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)
    • insertLeadingPI

      public static void insertLeadingPI​(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)
    • insertTrailingPI

      public static void insertTrailingPI​(org.w3c.dom.Document doc, java.lang.String target, java.lang.String data)
    • printNode

      public static void printNode​(org.w3c.dom.Node node, java.lang.String indent)
    • removeAttribute

      public static java.lang.String removeAttribute​(org.w3c.dom.Document doc, java.lang.String tagName, java.lang.String attribute)
    • serializeToByteArray

      public static byte[] serializeToByteArray​(org.w3c.dom.Document doc) throws java.io.IOException
      Throws:
      java.io.IOException
    • serializeToStringLS

      public static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc) throws java.io.IOException
      Serialize XML Document to string using DOM Level 3 Load/Save
      Parameters:
      doc - XML Document
      Returns:
      String representation of the Document
      Throws:
      java.io.IOException
    • serializeToStringLS

      public static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc, org.w3c.dom.Node node) throws java.io.IOException
      Serialize XML Document to string using DOM Level 3 Load/Save
      Parameters:
      doc - XML Document
      node - the Node to serialize
      Returns:
      String representation of the Document
      Throws:
      java.io.IOException
    • serializeToStringLS

      public static java.lang.String serializeToStringLS​(org.w3c.dom.Document doc, org.w3c.dom.Node node, java.lang.String encoding) throws java.io.IOException
      Serialize XML Node to string

      Note: this method is supposed to be faster than the Transform version but the output control is limited. If node is Document node, it will output XML PI which sometimes we want to avoid.

      Parameters:
      doc - XML document
      node - Node to be serialized
      encoding - encoding for the output
      Returns:
      String representation of the Document
      Throws:
      java.io.IOException
    • serializeToString

      public static java.lang.String serializeToString​(org.w3c.dom.Document doc) throws java.io.IOException
      Throws:
      java.io.IOException
    • serializeToString

      public static java.lang.String serializeToString​(org.w3c.dom.Node node, java.lang.String encoding) throws java.io.IOException
      Serialize XML Document to string using Transformer
      Parameters:
      node - the XML node (and the subtree rooted at this node) to be serialized
      encoding - encoding for the XML document
      Returns:
      String representation of the Document
      Throws:
      java.io.IOException
    • showXML

      public static void showXML​(org.w3c.dom.Document document)