Top Description Fields Constructors Methods
org.kxml2.kdom

public Class Node

extends Object
Class Inheritance
Known Direct Subclasses
org.kxml2.kdom.Document, org.kxml2.kdom.Element
Imports
java.util.*, java.io.*, org.xmlpull.v1.*

A common base class for Document and Element, also used for storing XML fragments.

Field Summary

Modifier and TypeField and Description
public static final int
protected Vector<E>
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
protected StringBuffer

Constructor Summary

AccessConstructor and Description
public
Node()

Method Summary

Modifier and TypeMethod and Description
public void
addChild(int index, int type, Object child)

inserts the given child object of the given type at the given index.

public void
addChild(int type, Object child)

convenience method for addChild (getChildCount (), child)

public Element
createElement(String namespace, String name)

Builds a default element with the given properties.

public Object
getChild(int index)

Returns the child object at the given index.

public int
getChildCount()

Returns the number of child objects

public Element
getElement(int index)

returns the element at the given index.

public Element
getElement(String namespace, String name)

Returns the element with the given namespace and name.

public String
getText(int index)

Returns the text node with the given index or null if the node with the given index is not a text node.

public int
getType(int index)

Returns the type of the child at the given index.

public int
indexOf(String namespace, String name, int startIndex)

Performs search for an element with the given namespace and name, starting at the given start index.

public boolean
isText(int i)

public void
parse(XmlPullParser parser)

Recursively builds the child elements from the given parser until an end tag or end document is found.

public void
removeChild(int idx)

Removes the child object at the given index

public void
write(XmlSerializer writer)

Writes this node to the given XmlWriter.

public void
writeChildren(XmlSerializer writer)

Writes the children of this node to the given XmlWriter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CDSECTback to summary
public static final int CDSECT
childrenback to summary
protected Vector<E> children
COMMENTback to summary
public static final int COMMENT
DOCDECLback to summary
public static final int DOCDECL
DOCUMENTback to summary
public static final int DOCUMENT
ELEMENTback to summary
public static final int ELEMENT
ENTITY_REFback to summary
public static final int ENTITY_REF
IGNORABLE_WHITESPACEback to summary
public static final int IGNORABLE_WHITESPACE
PROCESSING_INSTRUCTIONback to summary
public static final int PROCESSING_INSTRUCTION
TEXTback to summary
public static final int TEXT
typesback to summary
protected StringBuffer types

Constructor Detail

Nodeback to summary
public Node()

Method Detail

addChildback to summary
public void addChild(int index, int type, Object child)

inserts the given child object of the given type at the given index.

addChildback to summary
public void addChild(int type, Object child)

convenience method for addChild (getChildCount (), child)

createElementback to summary
public Element createElement(String namespace, String name)

Builds a default element with the given properties. Elements should always be created using this method instead of the constructor in order to enable construction of specialized subclasses by deriving custom Document classes.

Note

For no namespace, please use Xml.NO_NAMESPACE, null is not a legal value. Currently, null is converted to Xml.NO_NAMESPACE, but future versions may throw an exception.

getChildback to summary
public Object getChild(int index)

Returns the child object at the given index. For child elements, an Element object is returned. For all other child types, a String is returned.

getChildCountback to summary
public int getChildCount()

Returns the number of child objects

getElementback to summary
public Element getElement(int index)

returns the element at the given index. If the node at the given index is a text node, null is returned

getElementback to summary
public Element getElement(String namespace, String name)

Returns the element with the given namespace and name. If the element is not found, or more than one matching elements are found, an exception is thrown.

getTextback to summary
public String getText(int index)

Returns the text node with the given index or null if the node with the given index is not a text node.

getTypeback to summary
public int getType(int index)

Returns the type of the child at the given index. Possible types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION

indexOfback to summary
public int indexOf(String namespace, String name, int startIndex)

Performs search for an element with the given namespace and name, starting at the given start index. A null namespace matches any namespace, please use Xml.NO_NAMESPACE for no namespace). returns -1 if no matching element was found.

isTextback to summary
public boolean isText(int i)
parseback to summary
public void parse(XmlPullParser parser) throws IOException, XmlPullParserException

Recursively builds the child elements from the given parser until an end tag or end document is found. The end tag is not consumed.

removeChildback to summary
public void removeChild(int idx)

Removes the child object at the given index

writeback to summary
public void write(XmlSerializer writer) throws IOException

Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically.

writeChildrenback to summary
public void writeChildren(XmlSerializer writer) throws IOException

Writes the children of this node to the given XmlWriter.