Class Element
java.lang.Object
org.kxml2.kdom.Node
org.kxml2.kdom.Element
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.
-
Field Summary
Fields inherited from class Node
CDSECT, COMMENT, DOCDECL, DOCUMENT, ELEMENT, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, TEXT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()removes all children and attributescreateElement(String namespace, String name) Forwards creation request to parent if any, otherwise calls super.createElement.intReturns the number of attributes of this element.getAttributeName(int index) getAttributeNamespace(int index) getAttributeValue(int index) getAttributeValue(String namespace, String name) getName()returns the (local) name of the elementreturns the namespace of the elementintreturns the number of declared namespaces, NOT including parent elementsgetNamespacePrefix(int i) getNamespaceUri(int i) getNamespaceUri(String prefix) returns the namespace for the given prefixReturns the parent node of this elementgetRoot()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(org.xmlpull.v1.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 attributevoidsets the name of the elementvoidsetNamespace(String namespace) sets the namespace of the element.voidSets the given prefix; a namespace value of null removess the prefixvoidwrite(org.xmlpull.v1.XmlSerializer writer) Writes this element and all children to the given XmlWriter.Methods inherited from class Node
addChild, addChild, getChild, getChildCount, getElement, getElement, getText, getType, indexOf, isText, removeChild, writeChildren
-
Constructor Details
-
Element
public Element()
-
-
Method Details
-
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. -
clear
public void clear()removes all children and attributes -
createElement
Forwards creation request to parent if any, otherwise calls super.createElement.- Overrides:
createElementin classNode
-
getAttributeCount
public int getAttributeCount()Returns the number of attributes of this element. -
getAttributeNamespace
-
getAttributeName
-
getAttributeValue
-
getAttributeValue
-
getRoot
Returns the root node, determined by ascending to the all parents un of the root element. -
getName
returns the (local) name of the element -
getNamespace
returns the namespace of the element -
getNamespaceUri
-
getNamespaceCount
public int getNamespaceCount()returns the number of declared namespaces, NOT including parent elements -
getNamespacePrefix
-
getNamespaceUri
-
getParent
Returns the parent node of this element -
parse
public void parse(org.xmlpull.v1.XmlPullParser parser) throws IOException, org.xmlpull.v1.XmlPullParserException Builds the child elements from the given Parser. By overwriting parse, an element can take complete control over parsing its subtree.- Overrides:
parsein classNode- Throws:
IOExceptionorg.xmlpull.v1.XmlPullParserException
-
setAttribute
-
setPrefix
-
setName
sets the name of the element -
setNamespace
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. -
write
Writes this element and all children to the given XmlWriter.- Overrides:
writein classNode- Throws:
IOException
-