|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lightdev.lib.xml.parser.XmlParser
public class XmlParser
XmlParser is a parser for XML text
The parser does not support DOM, document type descriptions (DTDs) nor validation
of XML against DTDs. It simply parses XML text and
triggers a given instance of XmlParserCallback.
To use parsed contents in own applications a customized class that implements
interface XmlParserCallback must be used.
Usage example:
public class ExampleReader extends BufferedReader implements XmlParserCallback {
public ExampleReader(Reader in) {
super(in);
}
public void read(Object destination) throws IOException, IllegalCharacterException {
XmlParser p = new XmlParser(this);
String line = readLine();
while(line != null) {
p.parse(line);
line = readLine();
}
}
public void handleStartTag(String tagName, AttributeSet a) {
System.out.println("handleStartTag, tagName='" + tagName + "'");
}
public void handleEndTag(String tagName) {
System.out.println("handleEndTag, tagName='" + tagName + "'");
}
public void handleText(String text) {
System.out.println("handleText, text='" + text + "'");
}
}
XmlParserCallback| Field Summary | |
|---|---|
static char |
altAttrValueBorder
|
static char |
attrNameEnd
character indicating the start of an attribute value |
static char |
attrStart
character indicating the start of an attribute |
static char |
attrValueBorder
character indicating the start of an attribute value |
static char |
commentEnd
character indicating the end of a comment |
static char |
commentStart
character indicating the start of a comment |
static char |
endTagStart
character indicating the start of an end tag |
static char |
exChar
exclamation character |
static char |
qChar
question mark character |
static char |
special
character indicating special characters |
static char |
specialEnd
character indicating the end of a special character |
static char |
tagEnd
character indicating the end of a tag |
static char |
tagStart
character indicating the start of a tag |
| Constructor Summary | |
|---|---|
XmlParser(XmlParserCallback cb)
construct a new XmlParser |
|
| Method Summary | |
|---|---|
void |
parse(String data)
parse a text portion by going through each character of the data string and by driving the XmlParserCallback
according to the found data (start tags, attributes, end tags and content). |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char tagStart
public static final char tagEnd
public static final char endTagStart
public static final char qChar
public static final char exChar
public static final char attrStart
public static final char attrValueBorder
public static final char altAttrValueBorder
public static final char attrNameEnd
public static final char specialEnd
public static final char commentStart
public static final char commentEnd
public static final char special
| Constructor Detail |
|---|
public XmlParser(XmlParserCallback cb)
cb - the XmlParserCallback this parser calls to handle tags,
attributes and content foundXmlParserCallback| Method Detail |
|---|
public void parse(String data)
throws IllegalCharacterException
XmlParserCallback
according to the found data (start tags, attributes, end tags and content).
data - the data String to parse
IllegalCharacterExceptionXmlParserCallback
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||