MiniXmlPullParser

class MiniXmlPullParser(val source: CharIterator, val processNamespaces: Boolean = false, val relaxed: Boolean = false, val entityResolver: (String) -> String? = { null }) : XmlPullParser

A simple non-validating xml pull parser.

Constructors

Link copied to clipboard
constructor(source: String, processNamespaces: Boolean = false, relaxed: Boolean = false, entityResolver: (String) -> String? = { null })
constructor(source: CharIterator, processNamespaces: Boolean = false, relaxed: Boolean = false, entityResolver: (String) -> String? = { null })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var attributeCount: Int

The number of attributes of the current start tag, or -1 if the current event type is not START_TAG

Link copied to clipboard
open override var columnNumber: Int

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).

Link copied to clipboard
open override var depth: Int

Returns the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1 when a start tag is reached. The depth is decremented AFTER the end tag event was observed.

Link copied to clipboard
Link copied to clipboard
open override var eventType: EventType

Returns the type of the current event (START_TAG, END_TAG, TEXT, etc.)

Link copied to clipboard
open override var isEmptyElementTag: Boolean

True if the current event is START_TAG and the tag is degenerated (e.g. ); false otherwise.

Link copied to clipboard
open override var isWhitespace: Boolean

Checks whether the current TEXT event contains only whitespace characters.

Link copied to clipboard
open override var lastError: String
Link copied to clipboard
open override var lineNumber: Int

Returns the current line number, starting from 1.

Link copied to clipboard
open override var name: String

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.

Link copied to clipboard
open override var namespace: String

Returns the namespace URI of the current element. The default namespace is represented as empty string. If namespaces are not enabled, an empty string ("") is always returned. The current event must be START_TAG or END_TAG; otherwise, an empty string is returned.

Link copied to clipboard
open override val positionDescription: String

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.

Link copied to clipboard
open override var prefix: String

Returns the prefix of the current element.

Link copied to clipboard
Link copied to clipboard
val relaxed: Boolean = false
Link copied to clipboard
Link copied to clipboard
open override val text: String

Returns the text content of the current event as String.

Functions

Link copied to clipboard
open override fun getAttributeName(index: Int): String

Returns the local name of the specified attribute if namespaces are enabled or just attribute name if namespaces are disabled.

Link copied to clipboard
open override fun getAttributeNamespace(index: Int): String

Returns the namespace URI of the attribute with the given index (starts from 0).

Link copied to clipboard
open override fun getAttributePrefix(index: Int): String

Returns the prefix of the specified attribute.

Link copied to clipboard
open override fun getAttributeType(index: Int): String

Returns the type of the specified attribute.

Link copied to clipboard
open override fun getAttributeValue(index: Int): String

Returns the given attributes value.

open override fun getAttributeValue(namespace: String, name: String): String?

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.

Link copied to clipboard
open fun getNamespace(prefix: String): String?

Returns the URI corresponding to the given prefix, depending on current state of the parser.

Link copied to clipboard
open override fun getNamespaceCount(depth: Int): Int

Returns the numbers of elements in the namespace stack for the give depth.

Link copied to clipboard
open override fun getNamespacePrefix(pos: Int): String

Returns the namespace prefix for the given position in the namespace stack.

Link copied to clipboard
open override fun getNamespaceUri(pos: Int): String

Returns the namespace URI for the given position in the namespace stack.

Link copied to clipboard
open override fun isAttributeDefault(index: Int): Boolean

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:

Link copied to clipboard
open operator override fun next(): EventType

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.

Link copied to clipboard
open fun nextTag(): EventType

Call next() and return event if it is START_TAG or END_TAG otherwise throw an exception.

Link copied to clipboard
open fun nextText(): String

If current event is START_TAG then if next element is TEXT then element content is returned or if next event is END_TAG then empty string is returned, otherwise exception is thrown. After calling this function successfully parser will be positioned on END_TAG.

Link copied to clipboard
open override fun nextToken(): EventType

This method works similarly to next() but will expose additional event types (COMMENT, CDSECT, DOCDECL, ENTITY_REF, PROCESSING_INSTRUCTION, or IGNORABLE_WHITESPACE) if they are available in input.

Link copied to clipboard
open fun require(type: EventType?, namespace: String?, name: String?)

Test if the current event is of the given type and if the namespace and name do match.

Link copied to clipboard
open fun skipSubTree()

Skip sub tree that is currently porser positioned on.