org.kxml2.kdom
Class Node
public
class
Node
extends Object
A common base class for Document and Element, also used for
storing XML fragments.
Method Summary |
void | addChild(int index, int type, Object child) inserts the given child object of the given type at the
given index. |
void | addChild(int type, Object child) convenience method for addChild (getChildCount (), child) |
Element | createElement(String namespace, String name) Builds a default element with the given properties. |
Object | getChild(int index) Returns the child object at the given index. |
int | getChildCount() Returns the number of child objects |
Element | getElement(int index) returns the element at the given index. |
Element | getElement(String namespace, String name) Returns the element with the given namespace and name. |
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. |
int | getType(int index) Returns the type of the child at the given index. |
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. |
boolean | isText(int i) |
void | parse(XmlPullParser parser) Recursively builds the child elements from the given parser
until an end tag or end document is found.
|
void | removeChild(int idx) Removes the child object at the given index |
void | write(XmlSerializer writer) Writes this node to the given XmlWriter. |
void | writeChildren(XmlSerializer writer) Writes the children of this node to the given XmlWriter. |
public static final int CDSECT
public static final int COMMENT
public static final int DOCDECL
public static final int DOCUMENT
public static final int ELEMENT
public static final int ENTITY_REF
public static final int IGNORABLE_WHITESPACE
public static final int PROCESSING_INSTRUCTION
public static final int TEXT
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. 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. Please 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.
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.
public int getChildCount()
Returns the number of child objects
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
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.
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. Possible
types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION
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.
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.
The end tag is not consumed.
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. For node and document,
this method is identical to writeChildren, except that the
stream is flushed automatically.
public void writeChildren(XmlSerializer writer)
Writes the children of this node to the given XmlWriter.