edu.illinois.cs.cogcomp.lbj.coref.util.xml
Class SimpleXMLParser

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.util.xml.SimpleXMLParser

public class SimpleXMLParser
extends java.lang.Object

Author:
Eric Bengtson

Constructor Summary
SimpleXMLParser()
           
 
Method Summary
static java.lang.String getContentString(org.w3c.dom.Element tag)
           
static org.w3c.dom.Document getDocument(java.io.File file)
           
private static org.w3c.dom.Document getDocument(java.io.File file, javax.xml.parsers.DocumentBuilder docBuilder)
           
static org.w3c.dom.Document getDocument(java.lang.String filename)
           
private static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          UTILITY METHODS ***
static org.w3c.dom.Element getElement(org.w3c.dom.Element parent, java.lang.String tagName)
           
static java.lang.String getTagContent(org.w3c.dom.Element parent, java.lang.String tagName)
           
static java.lang.String getTagContent(org.w3c.dom.Element parent, java.lang.String tagName, java.lang.String defaultResult)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLParser

public SimpleXMLParser()
Method Detail

getDocument

public static org.w3c.dom.Document getDocument(java.lang.String filename)
                                        throws XMLException
Parameters:
filename - The file to parse
Returns:
The Document XML tag -- the root of the document.
Throws:
XMLException

getDocument

public static org.w3c.dom.Document getDocument(java.io.File file)
                                        throws XMLException
Parameters:
file - The file to parse.
Returns:
The Document XML tag -- the root of the document.
Throws:
XMLException

getElement

public static org.w3c.dom.Element getElement(org.w3c.dom.Element parent,
                                             java.lang.String tagName)
                                      throws XMLException
Parameters:
parent - The node containing the desired element tag
tagName - The name of the tag
Returns:
the first target element inside the parent Node.
Throws:
XMLException

getContentString

public static java.lang.String getContentString(org.w3c.dom.Element tag)
                                         throws XMLException
Parameters:
tag - (start) tag that encloses desired text.
Returns:
The contents of the tag.
Throws:
XMLException - If the tag has no children.

getTagContent

public static java.lang.String getTagContent(org.w3c.dom.Element parent,
                                             java.lang.String tagName)
                                      throws XMLException
Parameters:
parent - A node containing the tag enclosing desired text.
tagName - Name of tag containing desired text.
Returns:
The desired text.
Throws:
XMLException

getTagContent

public static java.lang.String getTagContent(org.w3c.dom.Element parent,
                                             java.lang.String tagName,
                                             java.lang.String defaultResult)
Parameters:
parent - A node containing the tag enclosing desired text.
tagName - Name of tag containing desired text.
Returns:
The desired text, or if tag not found, defaultResult.

getDocumentBuilder

private static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                             throws XMLException
UTILITY METHODS ***

Throws:
XMLException

getDocument

private static org.w3c.dom.Document getDocument(java.io.File file,
                                                javax.xml.parsers.DocumentBuilder docBuilder)
                                         throws XMLException
Throws:
XMLException