Package android.util
Class Xml
- java.lang.Object
-
- android.util.Xml
-
public class Xml extends Object
XML utility methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXml.EncodingSupported character encodings.
-
Field Summary
Fields Modifier and Type Field Description static StringFEATURE_RELAXEDXmlPullParser"relaxed" feature name.
-
Constructor Summary
Constructors Constructor Description Xml()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AttributeSetasAttributeSet(XmlPullParser parser)Return an AttributeSet interface for use with the given XmlPullParser.static Xml.EncodingfindEncodingByName(String encodingName)Finds an encoding by name.static XmlPullParsernewPullParser()Returns a new pull parser with namespace support.static XmlSerializernewSerializer()Creates a new xml serializer.static voidparse(InputStream in, Xml.Encoding encoding, ContentHandler contentHandler)Parses xml from the given input stream and fires events on the given SAX handler.static voidparse(Reader in, ContentHandler contentHandler)Parses xml from the given reader and fires events on the given SAX handler.static voidparse(String xml, ContentHandler contentHandler)Parses the given xml string and fires events on the given SAX handler.
-
-
-
Field Detail
-
FEATURE_RELAXED
public static String FEATURE_RELAXED
XmlPullParser"relaxed" feature name.- See Also:
- specification
-
-
Method Detail
-
parse
public static void parse(String xml, ContentHandler contentHandler) throws SAXException
Parses the given xml string and fires events on the given SAX handler.- Throws:
SAXException
-
parse
public static void parse(Reader in, ContentHandler contentHandler) throws IOException, SAXException
Parses xml from the given reader and fires events on the given SAX handler.- Throws:
IOExceptionSAXException
-
parse
public static void parse(InputStream in, Xml.Encoding encoding, ContentHandler contentHandler) throws IOException, SAXException
Parses xml from the given input stream and fires events on the given SAX handler.- Throws:
IOExceptionSAXException
-
newPullParser
public static XmlPullParser newPullParser()
Returns a new pull parser with namespace support.
-
newSerializer
public static XmlSerializer newSerializer()
Creates a new xml serializer.
-
findEncodingByName
public static Xml.Encoding findEncodingByName(String encodingName) throws UnsupportedEncodingException
Finds an encoding by name. Returns UTF-8 if you passnull.- Throws:
UnsupportedEncodingException
-
asAttributeSet
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:
AttributeSet
-
-