public class

Xml

extends Object
java.lang.Object
   ↳ android.util.Xml

Class Overview

XML utility methods.

Summary

Nested Classes
public class Xml.Encoding Supported character encodings. 
Fields
public static String FEATURE_RELAXED XmlPullParser "relaxed" feature name.
Public Constructors
Xml()
Public Methods
static AttributeSet asAttributeSet(XmlPullParser parser)
Return an AttributeSet interface for use with the given XmlPullParser.
static Xml.Encoding findEncodingByName(String encodingName)
Finds an encoding by name.
static XmlPullParser newPullParser()
Creates a new pull parser with namespace support.
static XmlSerializer newSerializer()
Creates a new xml serializer.
static void parse(String xml, ContentHandler contentHandler)
Parses the given xml string and fires events on the given SAX handler.
static void parse(Reader in, ContentHandler contentHandler)
Parses xml from the given reader and fires events on the given SAX handler.
static void parse(InputStream in, Xml.Encoding encoding, ContentHandler contentHandler)
Parses xml from the given input stream and fires events on the given SAX handler.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static String FEATURE_RELAXED

XmlPullParser "relaxed" feature name.

See Also

Public Constructors

public Xml ()

Public Methods

public static AttributeSet asAttributeSet (XmlPullParser parser)

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 The existing parser for which you would like an AttributeSet.
Returns
  • An AttributeSet you can use to retrieve the attribute values at each of the tags as the parser moves through its XML document.
See Also

public static Xml.Encoding findEncodingByName (String encodingName)

Finds an encoding by name. Returns UTF-8 if you pass null.

public static XmlPullParser newPullParser ()

Creates a new pull parser with namespace support.

Note: This is actually slower than the SAX parser, and it's not fully implemented. If you need a fast, mostly implemented pull parser, use this. If you need a complete implementation, use KXML.

public static XmlSerializer newSerializer ()

Creates a new xml serializer.

public static void parse (String xml, ContentHandler contentHandler)

Parses the given xml string and fires events on the given SAX handler.

Throws
SAXException

public static void parse (Reader in, ContentHandler contentHandler)

Parses xml from the given reader and fires events on the given SAX handler.

public static void parse (InputStream in, Xml.Encoding encoding, ContentHandler contentHandler)

Parses xml from the given input stream and fires events on the given SAX handler.