org.gcube.datatransformation.datatransformationlibrary.programs.metadata.util
Class XMLStringParser

java.lang.Object
  extended by org.gcube.datatransformation.datatransformationlibrary.programs.metadata.util.XMLStringParser

public class XMLStringParser
extends java.lang.Object

This class provides two helper methods which are used in order to convert between XML DOM trees and their string representation.

Author:
Spyros Boutsis, UoA

Constructor Summary
XMLStringParser()
           
 
Method Summary
static org.w3c.dom.Document parseXMLString(java.lang.String XMLdoc)
          Parses an XML string and transforms it to a DOM tree.
static java.lang.String XMLDocToString(org.w3c.dom.Node root)
          Converts a XML DOM tree to a XML string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStringParser

public XMLStringParser()
Method Detail

parseXMLString

public static org.w3c.dom.Document parseXMLString(java.lang.String XMLdoc)
                                           throws javax.xml.parsers.ParserConfigurationException,
                                                  org.xml.sax.SAXException,
                                                  java.io.IOException
Parses an XML string and transforms it to a DOM tree.

Parameters:
XMLdoc - The XML string to parse
Returns:
A Document object describing the DOM tree
Throws:
javax.xml.parsers.ParserConfigurationException - an error occured
org.xml.sax.SAXException - an error occured
java.io.IOException - an error occured

XMLDocToString

public static java.lang.String XMLDocToString(org.w3c.dom.Node root)
                                       throws java.lang.Exception
Converts a XML DOM tree to a XML string.

Parameters:
root - A Node object representing the root of the DOM tree to convert to a string.
Returns:
The XML string
Throws:
java.lang.Exception - an error occured