Stay organized with collections
Save and categorize content based on your preferences.
Xml
open class Xml
XML utility methods.
Summary
Nested classes |
|
Supported character encodings.
|
Public methods |
open static AttributeSet! |
Return an AttributeSet interface for use with the given XmlPullParser.
|
open static Xml.Encoding! |
Finds an encoding by name.
|
open static XmlPullParser! |
Returns a new pull parser with namespace support.
|
open static XmlSerializer! |
Creates a new xml serializer.
|
open static Unit |
Parses xml from the given input stream and fires events on the given SAX handler.
|
open static Unit |
Parses xml from the given reader and fires events on the given SAX handler.
|
open static Unit |
Parses the given xml string and fires events on the given SAX handler.
|
Public methods
asAttributeSet
open static fun asAttributeSet(parser: XmlPullParser!): AttributeSet!
Return an AttributeSet interface for use with the given XmlPullParser. If the given parser itself implements AttributeSet, that implementation is simply returned. Otherwise a wrapper class is instantiated on top of the XmlPullParser, as a proxy for retrieving its attributes, and returned to you.
Parameters |
parser |
XmlPullParser!: The existing parser for which you would like an AttributeSet. |
Return |
AttributeSet! |
An AttributeSet you can use to retrieve the attribute values at each of the tags as the parser moves through its XML document. |
findEncodingByName
open static fun findEncodingByName(encodingName: String!): Xml.Encoding!
Finds an encoding by name. Returns UTF-8 if you pass null
.
newPullParser
open static fun newPullParser(): XmlPullParser!
Returns a new pull parser with namespace support.
newSerializer
open static fun newSerializer(): XmlSerializer!
Creates a new xml serializer.
parse
open static fun parse(
in: Reader!,
contentHandler: ContentHandler!
): Unit
Parses xml from the given reader and fires events on the given SAX handler.
parse
open static fun parse(
xml: String!,
contentHandler: ContentHandler!
): Unit
Parses the given xml string and fires events on the given SAX handler.
Properties
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Xml\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nXml\n===\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/util/Xml \"View this page in Java\") \n\n```\nopen class Xml\n```\n\n|---|-----------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.util.Xml](#) |\n\nXML utility methods.\n\nSummary\n-------\n\n| Nested classes ||\n|---|----------------------------------------------------------------------------------------|\n| | [Encoding](/reference/kotlin/android/util/Xml.Encoding) Supported character encodings. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [AttributeSet](/reference/kotlin/android/util/AttributeSet)! | [asAttributeSet](#asAttributeSet(org.xmlpull.v1.XmlPullParser))`(`parser:` `[XmlPullParser](../../org/xmlpull/v1/XmlPullParser.html#)!`)` Return an AttributeSet interface for use with the given XmlPullParser. |\n| open static [Xml.Encoding](/reference/kotlin/android/util/Xml.Encoding)! | [findEncodingByName](#findEncodingByName(kotlin.String))`(`encodingName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Finds an encoding by name. |\n| open static [XmlPullParser](../../org/xmlpull/v1/XmlPullParser.html#)! | [newPullParser](#newPullParser())`()` Returns a new pull parser with namespace support. |\n| open static [XmlSerializer](../../org/xmlpull/v1/XmlSerializer.html#)! | [newSerializer](#newSerializer())`()` Creates a new xml serializer. |\n| open static [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [parse](#parse(java.io.InputStream,%20android.util.Xml.Encoding,%20org.xml.sax.ContentHandler))`(`in:` `[InputStream](../../java/io/InputStream.html#)!`, `encoding:` `[Xml.Encoding](/reference/kotlin/android/util/Xml.Encoding)!`, `contentHandler:` `[ContentHandler](../../org/xml/sax/ContentHandler.html#)!`)` Parses xml from the given input stream and fires events on the given SAX handler. |\n| open static [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [parse](#parse(java.io.Reader,%20org.xml.sax.ContentHandler))`(`in:` `[Reader](../../java/io/Reader.html#)!`, `contentHandler:` `[ContentHandler](../../org/xml/sax/ContentHandler.html#)!`)` Parses xml from the given reader and fires events on the given SAX handler. |\n| open static [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [parse](#parse(kotlin.String,%20org.xml.sax.ContentHandler))`(`xml:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `contentHandler:` `[ContentHandler](../../org/xml/sax/ContentHandler.html#)!`)` Parses the given xml string and fires events on the given SAX handler. |\n\n| Properties ||\n|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [FEATURE_RELAXED](#FEATURE_RELAXED:kotlin.String) [org.xmlpull.v1.XmlPullParser](../../org/xmlpull/v1/XmlPullParser.html#) \"relaxed\" feature name. |\n\nPublic methods\n--------------\n\n### asAttributeSet\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun asAttributeSet(parser: XmlPullParser!): AttributeSet!\n```\n\nReturn an AttributeSet interface for use with the given XmlPullParser. If the given parser itself implements AttributeSet, that implementation is simply returned. Otherwise a wrapper class is instantiated on top of the XmlPullParser, as a proxy for retrieving its attributes, and returned to you.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------------------|\n| `parser` | [XmlPullParser](../../org/xmlpull/v1/XmlPullParser.html#)!: The existing parser for which you would like an AttributeSet. |\n\n| Return ||\n|--------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| [AttributeSet](/reference/kotlin/android/util/AttributeSet)! | An AttributeSet you can use to retrieve the attribute values at each of the tags as the parser moves through its XML document. |\n\n**See Also**\n\n- [android.util.AttributeSet](/reference/kotlin/android/util/AttributeSet) \n\n### findEncodingByName\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun findEncodingByName(encodingName: String!): Xml.Encoding!\n```\n\nFinds an encoding by name. Returns UTF-8 if you pass `null`. \n\n### newPullParser\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun newPullParser(): XmlPullParser!\n```\n\nReturns a new pull parser with namespace support. \n\n### newSerializer\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun newSerializer(): XmlSerializer!\n```\n\nCreates a new xml serializer. \n\n### parse\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun parse(\n in: InputStream!, \n encoding: Xml.Encoding!, \n contentHandler: ContentHandler!\n): Unit\n```\n\nParses xml from the given input stream and fires events on the given SAX handler. \n\n### parse\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun parse(\n in: Reader!, \n contentHandler: ContentHandler!\n): Unit\n```\n\nParses xml from the given reader and fires events on the given SAX handler. \n\n### parse\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun parse(\n xml: String!, \n contentHandler: ContentHandler!\n): Unit\n```\n\nParses the given xml string and fires events on the given SAX handler.\n\nProperties\n----------\n\n### FEATURE_RELAXED\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic var FEATURE_RELAXED: String!\n```\n\n[org.xmlpull.v1.XmlPullParser](../../org/xmlpull/v1/XmlPullParser.html#) \"relaxed\" feature name. \n**See Also**"]]