scone.util
Class XMLHelper

java.lang.Object
  extended by scone.util.XMLHelper

public class XMLHelper
extends java.lang.Object

an XML helper class. This class provides easy parsing of XML documents and simple access methods for DOMs.


Constructor Summary
XMLHelper()
           
 
Method Summary
static org.w3c.dom.Node getAttribute(java.lang.String name, org.w3c.dom.Node node)
          returns the first attribute of node with the specified name, or null otherwise
static org.w3c.dom.Node getChild(java.lang.String name, org.w3c.dom.Node node)
          returns the first child node of node with the specified name, or null otherwise
static void main(java.lang.String[] args)
          test method
static org.w3c.dom.Document parseReader(java.io.Reader reader)
          parses a Reader into a DOM.
static void printNodeStructure(org.w3c.dom.Node node, java.lang.String indent)
          prints a simple structure of a Node and its children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLHelper

public XMLHelper()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
test method

Throws:
java.lang.Exception

parseReader

public static org.w3c.dom.Document parseReader(java.io.Reader reader)
                                        throws java.lang.Exception
parses a Reader into a DOM.

Parameters:
reader - a reader containing an XML document
Returns:
a DOM of the XML document
Throws:
java.lang.Exception

printNodeStructure

public static void printNodeStructure(org.w3c.dom.Node node,
                                      java.lang.String indent)
prints a simple structure of a Node and its children. Nice for debugging.

Parameters:
node - a Node
indent - set this to an empty String!

getAttribute

public static org.w3c.dom.Node getAttribute(java.lang.String name,
                                            org.w3c.dom.Node node)
returns the first attribute of node with the specified name, or null otherwise

Parameters:
name - the name of the attribute
node - the node
Returns:
the attribute as a node

getChild

public static org.w3c.dom.Node getChild(java.lang.String name,
                                        org.w3c.dom.Node node)
returns the first child node of node with the specified name, or null otherwise

Parameters:
name - the name of the child
node - the node
Returns:
the child