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 localName)

Constructs a new root element with the given name.

RootElement(String uri, String localName)

Constructs a new root element with the given name.

Public methods

ContentHandler getContentHandler()

Gets the SAX ContentHandler.

Inherited methods

Element getChild(String localName)

Gets the child element with the given name.

Element getChild(String uri, String localName)

Gets the child element with the given name.

Element requireChild(String localName)

Gets the child element with the given name.

Element requireChild(String uri, String localName)

Gets the child element with the given name.

void setElementListener(ElementListener elementListener)

Sets start and end element listeners at the same time.

void setEndElementListener(EndElementListener endElementListener)

Sets a listener for the end of this element.

void setEndTextElementListener(EndTextElementListener endTextElementListener)

Sets a listener for the end of this text element.

void setStartElementListener(StartElementListener startElementListener)

Sets a listener for the start of this element.

void setTextElementListener(TextElementListener elementListener)

Sets start and end text element listeners at the same time.

String toString()

Returns a string representation of the object.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

RootElement

Added in API level 1
public 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

RootElement

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

Constructs a new root element with the given name.

Parameters
uri String: the namespace

localName String: the local name

Public methods

getContentHandler

Added in API level 1
public ContentHandler getContentHandler ()

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

Returns
ContentHandler