Xml Pull Parser
KtXmplParser is an interface that defines parsing functionality based on the XMLPULL V2 API, adapted to Kotlin.
There are two key methods: next and nextToken. While next() provides access to high level parsing events, nextToken() allows access to lower level tokens.
The current event state of the parser can be determined by reading the eventType property. Initially, the parser is in the START_DOCUMENT state.
The method next() advances the parser to the next event. The enum value returned from next() determines the current parser state and is identical to the value returned from following calls to eventType.
Th following event types are seen by next():
EventType.START_TAG: An XML start tag was read.
EventType.TEXT: Text content was read. The text content can be retrieved using the text property (when in validating mode, next will not report ignorable whitespaces, use nextToken instead).
EventType.END_TAG: An end tag was read.
EventType.END_DOCUMENT: No more events are available
Author
Inheritors
Properties
The number of attributes of the current start tag, or -1 if the current event type is not START_TAG
Returns the current column number, starting from 0. When the parser does not know the current column number or can not determine it, -1 is returned (e.g. for WBXML).
True if the current event is START_TAG and the tag is degenerated (e.g.
Checks whether the current TEXT event contains only whitespace characters.
Returns the current line number, starting from 1.
For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled. When namespace processing is disabled, the raw name is returned. For ENTITY_REF events, the entity name is returned. If the current event is not START_TAG, END_TAG, or ENTITY_REF, an empty string is returned.
Returns a short text describing the current parser state, including the position, a description of the current event and the data source if known. This method is especially useful to provide meaningful error messages and for debugging purposes.
Functions
Returns the local name of the specified attribute if namespaces are enabled or just attribute name if namespaces are disabled.
Returns the namespace URI of the attribute with the given index (starts from 0).
Returns the prefix of the specified attribute.
Returns the type of the specified attribute.
Returns the given attributes value.
Returns the attributes value identified by namespace URI and namespace localName. If namespaces are disabled namespace must be null. If current event type is not START_TAG then IndexOutOfBoundsException will be thrown.
Returns the URI corresponding to the given prefix, depending on current state of the parser.
Returns the numbers of elements in the namespace stack for the give depth.
Returns the namespace prefix for the given position in the namespace stack.
Returns the namespace URI for the given position in the namespace stack.
Returns if the specified attribute was not in input was declared in XML. If parser is non-validating it MUST always return false. This information is part of XML infoset:
Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole element content (comments and processing instructions will be ignored and emtity references must be expanded or exception mus be thrown if entity reerence can not be exapnded). If element content is empty (content is "") then no TEXT event will be reported.
Skip sub tree that is currently porser positioned on.