FileDocCategorySizeDatePackage
Xml.javaAPI DocAndroid 1.5 API5983Wed May 06 22:41:56 BST 2009android.util

Xml

public class Xml extends Object
XML utility methods.

Fields Summary
public static String
FEATURE_RELAXED
{@link org.xmlpull.v1.XmlPullParser} "relaxed" feature name.
Constructors Summary
Methods Summary
public static AttributeSetasAttributeSet(org.xmlpull.v1.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.

param
parser The existing parser for which you would like an AttributeSet.
return
An AttributeSet you can use to retrieve the attribute values at each of the tags as the parser moves through its XML document.
see
AttributeSet

        return (parser instanceof AttributeSet)
                ? (AttributeSet) parser
                : new XmlPullAttributes(parser);
    
public static android.util.Xml$EncodingfindEncodingByName(java.lang.String encodingName)
Finds an encoding by name. Returns UTF-8 if you pass {@code null}.

        if (encodingName == null) {
            return Encoding.UTF_8;
        }

        for (Encoding encoding : Encoding.values()) {
            if (encoding.expatName.equalsIgnoreCase(encodingName))
                return encoding;
        }
        throw new UnsupportedEncodingException(encodingName);
    
public static org.xmlpull.v1.XmlPullParsernewPullParser()
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.

        ExpatPullParser parser = new ExpatPullParser();
        parser.setNamespaceProcessingEnabled(true);
        return parser;
    
public static org.xmlpull.v1.XmlSerializernewSerializer()
Creates a new xml serializer.

        try {
            return XmlSerializerFactory.instance.newSerializer();
        } catch (XmlPullParserException e) {
            throw new AssertionError(e);
        }
    
public static voidparse(java.lang.String xml, org.xml.sax.ContentHandler contentHandler)
Parses the given xml string and fires events on the given SAX handler.


                      
          
              
        try {
            XMLReader reader = new ExpatReader();
            reader.setContentHandler(contentHandler);
            reader.parse(new InputSource(new StringReader(xml)));
        }
        catch (IOException e) {
            throw new AssertionError(e);
        }
    
public static voidparse(java.io.Reader in, org.xml.sax.ContentHandler contentHandler)
Parses xml from the given reader and fires events on the given SAX handler.

        XMLReader reader = new ExpatReader();
        reader.setContentHandler(contentHandler);
        reader.parse(new InputSource(in));
    
public static voidparse(java.io.InputStream in, android.util.Xml$Encoding encoding, org.xml.sax.ContentHandler contentHandler)
Parses xml from the given input stream and fires events on the given SAX handler.

        try {
            XMLReader reader = new ExpatReader();
            reader.setContentHandler(contentHandler);
            InputSource source = new InputSource(in);
            source.setEncoding(encoding.expatName);
            reader.parse(source);
        } catch (IOException e) {
            throw new AssertionError(e);
        }