org.kxml2.kdom

Class Document

public class Document extends Node

The document consists of some legacy events and a single root element. This class basically adds some consistency checks to Node.
Method Summary
voidaddChild(int index, int type, Object child)
Adds a child at the given index position.
StringgetEncoding()
returns "#document"
StringgetName()
ElementgetRootElement()
returns the root element of this document.
BooleangetStandalone()
voidparse(XmlPullParser parser)
reads the document and checks if the last event is END_DOCUMENT.
voidremoveChild(int index)
voidsetEncoding(String enc)
voidsetStandalone(Boolean standalone)
voidwrite(XmlSerializer writer)
Writes this node to the given XmlWriter.

Method Detail

addChild

public void addChild(int index, int type, Object child)
Adds a child at the given index position. Throws an exception when a second root element is added

getEncoding

public String getEncoding()
returns "#document"

getName

public String getName()

getRootElement

public Element getRootElement()
returns the root element of this document.

getStandalone

public Boolean getStandalone()

parse

public void parse(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 ().

removeChild

public void removeChild(int index)

setEncoding

public void setEncoding(String enc)

setStandalone

public void setStandalone(Boolean standalone)

write

public void write(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.