Skip to content

Most visited

Recently visited

navigation
Added in API level 1

RootElement

public class RootElement
extends Element

java.lang.Object
   ↳ android.sax.Element
     ↳ android.sax.RootElement


The root XML element. The entry point for this API. Not safe for concurrent use.

For example, passing this XML:

 <feed xmlns='http://www.w3.org/2005/Atom'>
   <entry>
     <id>bob</id>
   </entry>
 </feed>
 
to this code:
 static final String ATOM_NAMESPACE = "http://www.w3.org/2005/Atom";

 ...
 
 RootElement root = new RootElement(ATOM_NAMESPACE, "feed");
 Element entry = root.getChild(ATOM_NAMESPACE, "entry");
 entry.getChild(ATOM_NAMESPACE, "id").setEndTextElementListener(
   new EndTextElementListener() {
     public void end(String body) {
       System.out.println("Entry ID: " + body);
     }
   });

 XMLReader reader = ...;
 reader.setContentHandler(root.getContentHandler());
 reader.parse(...);
 
would output:
 Entry ID: bob
 

Summary

Public constructors

RootElement(String uri, String localName)

Constructs a new root element with the given name.

RootElement(String localName)

Constructs a new root element with the given name.

Public methods

ContentHandler getContentHandler()

Gets the SAX ContentHandler.

Inherited methods

From class android.sax.Element
From class java.lang.Object

Public constructors

RootElement

Added in API level 1
RootElement (String uri, 
                String localName)

Constructs a new root element with the given name.

Parameters
uri String: the namespace
localName String: the local name

RootElement

Added in API level 1
RootElement (String localName)

Constructs a new root element with the given name. Uses an empty string as the namespace.

Parameters
localName String: the local name

Public methods

getContentHandler

Added in API level 1
ContentHandler getContentHandler ()

Gets the SAX ContentHandler. Pass this to your SAX parser.

Returns
ContentHandler
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.