XMLParser

This class implements a simple XML pull parser. Only a subset of the XML pull parser API is implemented.

Methods
XMLParser(String xml)
Construct a new XML parser.
XMLParser(String xml)
Construct a new XML parser.
Parameters:
xml - the document
int getAttributeCount()
Get the number of attributes.
int getAttributeCount()
Get the number of attributes.
Returns:
the attribute count
String getAttributeLocalName(int index)
Get the local name of the attribute.
String getAttributeLocalName(int index)
Get the local name of the attribute.
Parameters:
index - the index of the attribute (starting with 0)
Returns:
the local name
String getAttributePrefix(int index)
Get the prefix of the attribute.
String getAttributePrefix(int index)
Get the prefix of the attribute.
Parameters:
index - the index of the attribute (starting with 0)
Returns:
the prefix
int getEventType()
Get the event type of the current token.
int getEventType()
Get the event type of the current token.
Returns:
the event type
String getLocalName()
Get the local name of the current start or end element.
String getLocalName()
Get the local name of the current start or end element.
Returns:
the local name
String getName()
Get the full name of the current start or end element.
String getName()
Get the full name of the current start or end element. If there is no prefix, only the local name is returned, otherwise the prefix, ':', and the local name.
Returns:
the full name
int getPos()
Get the current character position in the XML document.
int getPos()
Get the current character position in the XML document.
Returns:
the position
String getPrefix()
Get the prefix of the current start or end element.
String getPrefix()
Get the prefix of the current start or end element.
Returns:
the prefix
String getRemaining()
Get the remaining XML text of the document.
String getRemaining()
Get the remaining XML text of the document.
Returns:
the remaining XML
String getText()
Get the current text.
String getText()
Get the current text.
Returns:
the text
String getToken()
Get the current token text.
String getToken()
Get the current token text.
Returns:
the token
boolean hasNext()
Check if there are more tags to read.
boolean hasNext()
Check if there are more tags to read.
Returns:
true if there are more tags
boolean isWhiteSpace()
Check if the current character tag only contains spaces or other non-printable characters.
boolean isWhiteSpace()
Check if the current character tag only contains spaces or other non-printable characters.
Returns:
if the trimmed text is empty
int ()
Read the next tag.
int ()
Read the next tag.
Returns:
the event type of the next tag
void setHTML(boolean html)
Enable or disable HTML processing.
void setHTML(boolean html)
Enable or disable HTML processing. When enabled, attributes don't need to have values.
Parameters:
html - true if HTML processing is enabled.

Fields
static int CHARACTERS = 4
static int COMMENT = 5
static int DTD = 11
static int END_DOCUMENT = 8
static int END_ELEMENT = 2
static int ERROR = 0
static int PROCESSING_INSTRUCTION = 3
static int START_DOCUMENT = 7
static int START_ELEMENT = 1

ERROR = 0

This event type means an error occurred.

START_ELEMENT = 1

This event type means a start element has been read.

DTD = 11

This event type means a DTD element has been read.

END_ELEMENT = 2

This event type means an end element has been read.

PROCESSING_INSTRUCTION = 3

This event type means a processing instruction has been read.

CHARACTERS = 4

This event type means text has been read.

COMMENT = 5

This event type means a comment has been read.

START_DOCUMENT = 7

This event type is used before reading.

END_DOCUMENT = 8

This event type means the end of the document has been reached.