org.kxml2.kdom

Class Element

public class Element extends Node

In order to create an element, please use the createElement method instead of invoking the constructor directly. The right place to add user defined initialization code is the init method.
Constructor Summary
Element()
Method Summary
voidclear()
removes all children and attributes
ElementcreateElement(String namespace, String name)
Forwards creation request to parent if any, otherwise calls super.createElement.
intgetAttributeCount()
Returns the number of attributes of this element.
StringgetAttributeName(int index)
StringgetAttributeNamespace(int index)
StringgetAttributeValue(int index)
StringgetAttributeValue(String namespace, String name)
StringgetName()
returns the (local) name of the element
StringgetNamespace()
returns the namespace of the element
intgetNamespaceCount()
returns the number of declared namespaces, NOT including parent elements
StringgetNamespacePrefix(int i)
StringgetNamespaceUri(String prefix)
returns the namespace for the given prefix
StringgetNamespaceUri(int i)
NodegetParent()
Returns the parent node of this element
NodegetRoot()
Returns the root node, determined by ascending to the all parents un of the root element.
voidinit()
called when all properties are set, but before children are parsed.
voidparse(XmlPullParser parser)
Builds the child elements from the given Parser.
voidsetAttribute(String namespace, String name, String value)
Sets the given attribute; a value of null removes the attribute
voidsetName(String name)
sets the name of the element
voidsetNamespace(String namespace)
sets the namespace of the element.
voidsetPrefix(String prefix, String namespace)
Sets the given prefix; a namespace value of null removess the prefix
voidwrite(XmlSerializer writer)
Writes this element and all children to the given XmlWriter.

Constructor Detail

Element

public Element()

Method Detail

clear

public void clear()
removes all children and attributes

createElement

public Element createElement(String namespace, String name)
Forwards creation request to parent if any, otherwise calls super.createElement.

getAttributeCount

public int getAttributeCount()
Returns the number of attributes of this element.

getAttributeName

public String getAttributeName(int index)

getAttributeNamespace

public String getAttributeNamespace(int index)

getAttributeValue

public String getAttributeValue(int index)

getAttributeValue

public String getAttributeValue(String namespace, String name)

getName

public String getName()
returns the (local) name of the element

getNamespace

public String getNamespace()
returns the namespace of the element

getNamespaceCount

public int getNamespaceCount()
returns the number of declared namespaces, NOT including parent elements

getNamespacePrefix

public String getNamespacePrefix(int i)

getNamespaceUri

public String getNamespaceUri(String prefix)
returns the namespace for the given prefix

getNamespaceUri

public String getNamespaceUri(int i)

getParent

public Node getParent()
Returns the parent node of this element

getRoot

public Node getRoot()
Returns the root node, determined by ascending to the all parents un of the root element.

init

public void init()
called when all properties are set, but before children are parsed. Please do not use setParent for initialization code any longer.

parse

public void parse(XmlPullParser parser)
Builds the child elements from the given Parser. By overwriting parse, an element can take complete control over parsing its subtree.

setAttribute

public void setAttribute(String namespace, String name, String value)
Sets the given attribute; a value of null removes the attribute

setName

public void setName(String name)
sets the name of the element

setNamespace

public void setNamespace(String namespace)
sets the namespace of the element. 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.

setPrefix

public void setPrefix(String prefix, String namespace)
Sets the given prefix; a namespace value of null removess the prefix

write

public void write(XmlSerializer writer)
Writes this element and all children to the given XmlWriter.