
Minimal non-validating XML pull parser using CharIterator for input, reducing null returns and removing factories. Ideal for lightweight XML parsing in diverse environments.
Minimal platform-agnostic non-validating XML pull parser based on kxml2.
The most significant changes (relative to XmlPull / KXml2) are:
Import in build.gradle.kts for a "shared" KMP module:
(...)
kotlin {
(...)
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.kobjects.ktxml:core:0.3.2")
(...)
}
}
(...)
KtXML is implemented in pure Kotlin, so it should work on all platforms supported by Kotlin.
The most important calls in KtXml are next() and nextToken().
next() moves to the next "high level" token and returns the token type. It skips over
comments and processing instructions and automatically decodes entity references. It also might
aggregate text content.
nextToken() moves to the next "low level" token including whitespace, processing instructions,
comments and entity references.
After a call to next() or nextToken(), the details of the current token (such as tag attributes)
can be queried from the parser; see XmlPullParser
Typically these calls are used to implement recursive descend parsing of a specific XML format.
Please always use the interface (XmlPullParser) and never the concrete parser implementation (MiniXmlPullParser) when passing the parser around.
For a set of small code examples, please take a look at the test.
For more information about the API, please refer to the KtXml API documentation.
See https://github.com/kobjects/ktxml/issues/6
If you are missing anything from kXML2, please file a feature request by creating a corresponding issue in the github issue tracker.
Please file an issue before creating a PR.
Please try to keep PRs as "atomic" as possible, i.e. addressing one issue only. I can push library / Kotlin / Gradle versions up as needed beforehand where this helps.
Please file an issue using the github issue tracker.
Brainstorming document: https://docs.google.com/document/d/1OXG5F5I-Gp-65cN8THWB1LMTZDnRS96CIBenPcusDDA/edit?usp=sharing
Minimal platform-agnostic non-validating XML pull parser based on kxml2.
The most significant changes (relative to XmlPull / KXml2) are:
Import in build.gradle.kts for a "shared" KMP module:
(...)
kotlin {
(...)
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.kobjects.ktxml:core:0.3.2")
(...)
}
}
(...)
KtXML is implemented in pure Kotlin, so it should work on all platforms supported by Kotlin.
The most important calls in KtXml are next() and nextToken().
next() moves to the next "high level" token and returns the token type. It skips over
comments and processing instructions and automatically decodes entity references. It also might
aggregate text content.
nextToken() moves to the next "low level" token including whitespace, processing instructions,
comments and entity references.
After a call to next() or nextToken(), the details of the current token (such as tag attributes)
can be queried from the parser; see XmlPullParser
Typically these calls are used to implement recursive descend parsing of a specific XML format.
Please always use the interface (XmlPullParser) and never the concrete parser implementation (MiniXmlPullParser) when passing the parser around.
For a set of small code examples, please take a look at the test.
For more information about the API, please refer to the KtXml API documentation.
See https://github.com/kobjects/ktxml/issues/6
If you are missing anything from kXML2, please file a feature request by creating a corresponding issue in the github issue tracker.
Please file an issue before creating a PR.
Please try to keep PRs as "atomic" as possible, i.e. addressing one issue only. I can push library / Kotlin / Gradle versions up as needed beforehand where this helps.
Please file an issue using the github issue tracker.
Brainstorming document: https://docs.google.com/document/d/1OXG5F5I-Gp-65cN8THWB1LMTZDnRS96CIBenPcusDDA/edit?usp=sharing