Methods Summary |
---|
public void | addChild(int index, int type, java.lang.Object child)Adds a child at the given index position. Throws
an exception when a second root element is added
if (type == ELEMENT) {
// if (rootIndex != -1)
// throw new RuntimeException("Only one document root element allowed");
rootIndex = index;
}
else if (rootIndex >= index)
rootIndex++;
super.addChild(index, type, child);
|
public java.lang.String | getEncoding()returns "#document"
return encoding;
|
public java.lang.String | getName()
return "#document";
|
public org.kxml2.kdom.Element | getRootElement()returns the root element of this document.
if (rootIndex == -1)
throw new RuntimeException("Document has no root element!");
return (Element) getChild(rootIndex);
|
public java.lang.Boolean | getStandalone()
return standalone;
|
public void | parse(org.xmlpull.v1.XmlPullParser parser)reads the document and checks if the last event
is END_DOCUMENT. If not, an exception is thrown.
The end event is consumed. For parsing partial
XML structures, consider using Node.parse ().
parser.require(XmlPullParser.START_DOCUMENT, null, null);
parser.nextToken ();
encoding = parser.getInputEncoding();
standalone = (Boolean)parser.getProperty ("http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone");
super.parse(parser);
if (parser.getEventType() != XmlPullParser.END_DOCUMENT)
throw new RuntimeException("Document end expected!");
|
public void | removeChild(int index)
if (index == rootIndex)
rootIndex = -1;
else if (index < rootIndex)
rootIndex--;
super.removeChild(index);
|
public void | setEncoding(java.lang.String enc)
this.encoding = enc;
|
public void | setStandalone(java.lang.Boolean standalone)
this.standalone = standalone;
|
public void | write(org.xmlpull.v1.XmlSerializer writer)Writes this node to the given XmlWriter. For node and document,
this method is identical to writeChildren, except that the
stream is flushed automatically.
writer.startDocument(encoding, standalone);
writeChildren(writer);
writer.endDocument();
|