public class RootElement extends Element
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
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
ContentHandler |
getContentHandler()
Gets the SAX
ContentHandler . |
getChild, getChild, requireChild, requireChild, setElementListener, setEndElementListener, setEndTextElementListener, setStartElementListener, setTextElementListener, toString
public RootElement(String uri, String localName)
uri
- the namespacelocalName
- the local namepublic RootElement(String localName)
localName
- the local namepublic ContentHandler getContentHandler()
ContentHandler
. Pass this to your SAX parser.