Package org.kxml2.kdom
Class Node
java.lang.Object
org.kxml2.kdom.Node
A common base class for Document and Element, also used for
storing XML fragments.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
inserts the given child object of the given type at the given index.void
convenience method for addChild (getChildCount (), child)createElement
(String namespace, String name) Builds a default element with the given properties.getChild
(int index) Returns the child object at the given index.int
Returns the number of child objectsgetElement
(int index) returns the element at the given index.getElement
(String namespace, String name) Returns the element with the given namespace and name.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
Performs search for an element with the given namespace and name, starting at the given start index.boolean
isText
(int i) void
parse
(org.xmlpull.v1.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 indexvoid
write
(org.xmlpull.v1.XmlSerializer writer) Writes this node to the given XmlWriter.void
writeChildren
(org.xmlpull.v1.XmlSerializer writer) Writes the children of this node to the given XmlWriter.
-
Field Details
-
DOCUMENT
public static final int DOCUMENT- See Also:
-
ELEMENT
public static final int ELEMENT- See Also:
-
TEXT
public static final int TEXT- See Also:
-
CDSECT
public static final int CDSECT- See Also:
-
ENTITY_REF
public static final int ENTITY_REF- See Also:
-
IGNORABLE_WHITESPACE
public static final int IGNORABLE_WHITESPACE- See Also:
-
PROCESSING_INSTRUCTION
public static final int PROCESSING_INSTRUCTION- See Also:
-
COMMENT
public static final int COMMENT- See Also:
-
DOCDECL
public static final int DOCDECL- See Also:
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
addChild
inserts the given child object of the given type at the given index. -
addChild
convenience method for addChild (getChildCount (), child) -
createElement
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. -
getChild
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. -
getChildCount
public int getChildCount()Returns the number of child objects -
getElement
returns the element at the given index. If the node at the given index is a text node, null is returned -
getElement
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. -
getText
Returns the text node with the given index or null if the node with the given index is not a text node. -
getType
public int getType(int index) Returns the type of the child at the given index. Possible types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION -
indexOf
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. -
isText
public boolean isText(int i) -
parse
public void parse(org.xmlpull.v1.XmlPullParser parser) throws IOException, org.xmlpull.v1.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.- Throws:
IOException
org.xmlpull.v1.XmlPullParserException
-
removeChild
public void removeChild(int idx) Removes the child object at the given index -
write
Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically.- Throws:
IOException
-
writeChildren
Writes the children of this node to the given XmlWriter.- Throws:
IOException
-