Added in API level 1

RootElement


open class RootElement : 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
  

Summary

Public constructors
RootElement(localName: String!)

Constructs a new root element with the given name.

RootElement(uri: String!, localName: String!)

Constructs a new root element with the given name.

Public methods
open ContentHandler!

Gets the SAX ContentHandler.

Inherited functions
Element! getChild(localName: String!)

Gets the child element with the given name. Uses an empty string as the namespace.

Element! getChild(uri: String!, localName: String!)

Gets the child element with the given name.

Element! requireChild(localName: String!)

Gets the child element with the given name. Uses an empty string as the namespace. We will throw a org.xml.sax.SAXException at parsing time if the specified child is missing. This helps you ensure that your listeners are called.

Element! requireChild(uri: String!, localName: String!)

Gets the child element with the given name. We will throw a org.xml.sax.SAXException at parsing time if the specified child is missing. This helps you ensure that your listeners are called.

Unit setElementListener(elementListener: ElementListener!)

Sets start and end element listeners at the same time.

Unit setEndElementListener(endElementListener: EndElementListener!)

Sets a listener for the end of this element.

Unit setEndTextElementListener(endTextElementListener: EndTextElementListener!)

Sets a listener for the end of this text element.

Unit setStartElementListener(startElementListener: StartElementListener!)

Sets a listener for the start of this element.

Unit setTextElementListener(elementListener: TextElementListener!)

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

String toString()

Public constructors

RootElement

Added in API level 1
RootElement(localName: String!)

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
RootElement(
    uri: String!,
    localName: String!)

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
open fun getContentHandler(): ContentHandler!

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