|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.autonomy.utilities.EventDrivenXMLParser
EventDrivenXMLParser
is a simple stream-oriented parser. As the parser recognizes parts of the document
it will call the appropriate handler for that part. This class should be extended and the handler methods overridden
in order to implement your desired functionality (the handler methods of this class simply print the xml to standard
output).
The handler methods are:
startElementHandler
- called when an xml element start tag is encountered.endElementHandler
- called when an xml element end tag is encountered.charDataHandler
- called when character data is found.com.autonomy.client.XML2ACIParser
class.
Also note that the xml can be fed to the parser piece by piece as shown in the third example below.
Usage:
EventDrivenXMLParser parser = new EventDrivenXMLParser();
parser.setXML(sXML)
parser.parse();
or
EventDrivenXMLParser parser = new EventDrivenXMLParser(sXML);
parser.parse();
or
EventDrivenXMLParser parser = new EventDrivenXMLParser();
parser.parse(sXML1);
parser.parse(sXML2);
parser.parse(sXML3);
Field Summary | |
static int |
PARSE_BAD_TAG
|
static int |
PARSE_EMPTY_TAG
|
static int |
PARSE_END_TAG
|
static int |
PARSE_START_TAG
|
static int |
PARSE_XML_TAG
|
Constructor Summary | |
EventDrivenXMLParser()
Default constructor |
|
EventDrivenXMLParser(java.lang.String sXML)
Constructor for EventDrivenXMLParser. |
Method Summary | |
void |
charDataHandler(java.lang.String sCharData)
Called when the parser encounters character data. |
void |
endElementHandler(java.lang.String sTagName)
Called when the parser encounters an xml element's end tag. |
void |
parse()
Parse the previoulsy specified xml string. |
void |
parse(java.lang.String sXML)
Parse the xml string. |
void |
setXML(java.lang.String sXML)
Sets sXML as the buffer to be parsed. |
void |
startElementHandler(java.lang.String sTagName,
java.util.Hashtable htAttributes)
Called when the parser encounters an xml element's start tag. |
void |
XMLElementHandler(java.lang.String sTagName,
java.util.Hashtable htAttributes)
Called when the parser encounters The |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PARSE_START_TAG
public static final int PARSE_END_TAG
public static final int PARSE_EMPTY_TAG
public static final int PARSE_BAD_TAG
public static final int PARSE_XML_TAG
Constructor Detail |
public EventDrivenXMLParser()
public EventDrivenXMLParser(java.lang.String sXML)
sXML
- the XML to be parsed.Method Detail |
public void setXML(java.lang.String sXML)
sXML
- the XML to be parsed.public void parse(java.lang.String sXML)
sXML
- the XML to be parsed.public void XMLElementHandler(java.lang.String sTagName, java.util.Hashtable htAttributes)
sTagName
- the name of the xml element.htAttributes
- a Hashtable containing the xml element's attributes in key-value pairs. The attribute
names are used as the table's keys and the attribute values are the corresponding table values. If there are no
attributes this Hashtable is empty.public void startElementHandler(java.lang.String sTagName, java.util.Hashtable htAttributes)
sTagName
- the name of the xml element.htAttributes
- a Hashtable containing the xml element's attributes in key-value pairs. The attribute
names are used as the table's keys and the attribute values are the corresponding table values. If there are no
attributes this Hashtable is empty.public void endElementHandler(java.lang.String sTagName)
sTagName
- the name of the xml element.public void charDataHandler(java.lang.String sCharData)
sCharData
- the character data.public void parse()
setXML(String sXML)
.
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |