FileDocCategorySizeDatePackage
RootElement.javaAPI DocAndroid 1.5 API6151Wed May 06 22:42:00 BST 2009android.sax

RootElement

public class RootElement extends Element
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

Fields Summary
final Handler
handler
Constructors Summary
public RootElement(String uri, String localName)
Constructs a new root element with the given name.

param
uri the namespace
param
localName the local name


                           
         
        super(null, uri, localName, 0);
    
public RootElement(String localName)
Constructs a new root element with the given name. Uses an empty string as the namespace.

param
localName the local name

        this("", localName);
    
Methods Summary
public org.xml.sax.ContentHandlergetContentHandler()
Gets the SAX {@code ContentHandler}. Pass this to your SAX parser.

        return this.handler;