nl.knmi.orfeus.seedlink
Class XMLParser

java.lang.Object
  extended by nl.knmi.orfeus.seedlink.XMLParser

public class XMLParser
extends java.lang.Object


Method Summary
static java.lang.String documentToString(Document document)
          Parses SeedLink XML into a String.
static java.lang.String elementToString(Element element)
          Parses SeedLink XML Element into a String.
static Document parse(java.lang.String xml)
          Parses SeedLink XML into a org.dom4j.Document object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static Document parse(java.lang.String xml)
                      throws DocumentException
Parses SeedLink XML into a org.dom4j.Document object.

Parameters:
xml - XML source returned by a SeedLink INFO request.
Returns:
a org.dom4j.Document object

Example usage:


 infoLevel = slconn.getInfoString();

 // print raw XML
 // System.out.println(infoLevel);

 if (infoLevel == null)
     throw (new DatabaseException("ERROR: Invalid INFO response"));

 // parse XML to String
 Document document = XMLParser.parse(infoLevel);

 // print doc contents in readable format
 System.out.println(XMLParser.documentToString(document));

 // do something with document...
 

Throws:
DocumentException - on error reading XML into Document
See Also:
SLClient.packetHandler(int, SLPacket), SeedLinkConnection.getInfoString()

documentToString

public static java.lang.String documentToString(Document document)
                                         throws DocumentException
Parses SeedLink XML into a String.

Parameters:
document - a org.dom4j.Document object containing SeedLink XML .
Returns:
a String representation of this SeedLink XML Document
Throws:
DocumentException

elementToString

public static java.lang.String elementToString(Element element)
                                        throws DocumentException
Parses SeedLink XML Element into a String.

Parameters:
element - a org.dom4j.Element object containing SeedLink XML .
Returns:
a String representation of this SeedLink XML Element
Throws:
DocumentException