Class XmlElement
java.lang.Object
org.libxmq.imp.xml.XmlNode
org.libxmq.imp.xml.XmlElement
- All Implemented Interfaces:
XMQElement, XMQNode
An element. Attributes are kept in source order. Namespace declarations
(xmlns and xmlns:prefix) are not attributes, they are stored in the
nsDef list, like in libxml2.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an attribute last, like libxml2 xmlNewProp.Find an attribute without a namespace by its name.attributeByFullName(String full_name) Find an attribute by its full name, ie prefix:name.Returns the attributes, in source order.attributeValue(String name) Returns the value of an attribute.Declare a namespace on this element, like libxml2 xmlNewNs.Returns the first child element with the given name.elements()Returns the element children.fullName()Returns the full name, ie prefix:name if the node has a namespace with a prefix.ns()Returns the namespace of the element.nsDefs()Returns the namespace declarations on this element, in source order.voidRemove an attribute.Search the namespace declared for the prefix on this element or its ancestors, like libxml2 xmlSearchNs.setAttribute(String name, String value) Add or replace an attribute with a text value.voidSet the namespace of the element.type()Returns the type of this node.Methods inherited from class XmlNode
addChild, addNextSibling, addPrevSibling, appendRaw, children, content, doc, firstChild, hasChildren, lastChild, line, name, next, numChildren, parent, prev, replaceWith, setContent, setLine, setName, textContent, toString, unlinkModifier and TypeMethodDescriptionAdd a child like libxml2 xmlAddChild.Insert a sibling after this node, like libxml2 xmlAddNextSibling (but without text merging).Insert a sibling before this node, like libxml2 xmlAddPrevSibling (but without text merging).Append a child without merging adjacent text nodes.children()Returns a new list with the children of this node.content()Returns the text content of text like nodes (text, cdata, comment, pi).doc()Returns the document owning this node.Returns the first child.booleanReturns true if this node has children.Returns the last child.intline()Returns the source line of the node, like libxml2 xmlGetLineNo: elements get the line where their start tag ends, text the line where its first chunk was read, comments, processing instructions and cdata sections the line where they end.name()Returns the name of the node.next()Returns the next sibling.intCount the children.parent()Returns the parent node.prev()Returns the previous sibling.voidReplace this node with another node, like libxml2 xmlReplaceNode.voidsetContent(String content) Set the content of a text like node.voidsetLine(int line) Set the source line of the node.voidSet the name of the node.Returns the string value of the node, like libxml2 xmlNodeGetContent.toString()voidunlink()Remove this node from its parent and siblings, like libxml2 xmlUnlinkNode.
-
Field Details
-
XML_NS
The predefined xml namespace.
-
-
Constructor Details
-
XmlElement
Create an element.- Parameters:
name- The local name, ie without a namespace prefix.
-
-
Method Details
-
type
-
ns
Returns the namespace of the element.- Specified by:
nsin interfaceXMQElement- Returns:
- The namespace or null.
-
setNs
Set the namespace of the element.- Specified by:
setNsin interfaceXMQElement- Parameters:
ns- The namespace or null.
-
nsDefs
-
declareNs
Declare a namespace on this element, like libxml2 xmlNewNs. If the prefix is already declared on this element, the existing declaration is returned unchanged, also when its uri differs (libxml2 xmlNewNs returns NULL instead).- Specified by:
declareNsin interfaceXMQElement- Parameters:
prefix- The prefix, null for the default namespace.uri- The namespace uri.- Returns:
- The new or the existing namespace declaration.
-
searchNs
Search the namespace declared for the prefix on this element or its ancestors, like libxml2 xmlSearchNs.- Specified by:
searchNsin interfaceXMQElement- Parameters:
prefix- The prefix, null for the default namespace.- Returns:
- The namespace or null.
-
attributes
-
addAttribute
Add an attribute last, like libxml2 xmlNewProp.- Specified by:
addAttributein interfaceXMQElement- Parameters:
a- The attribute.- Returns:
- The attribute.
-
setAttribute
Add or replace an attribute with a text value.- Specified by:
setAttributein interfaceXMQElement- Parameters:
name- The attribute name.value- The value.- Returns:
- The attribute.
-
removeAttribute
Remove an attribute.- Specified by:
removeAttributein interfaceXMQElement- Parameters:
a- The attribute to remove.
-
attribute
Find an attribute without a namespace by its name.- Specified by:
attributein interfaceXMQElement- Parameters:
name- The name.- Returns:
- The attribute or null.
-
attributeByFullName
Find an attribute by its full name, ie prefix:name.- Specified by:
attributeByFullNamein interfaceXMQElement- Parameters:
full_name- The full name.- Returns:
- The attribute or null.
-
attributeValue
Returns the value of an attribute.- Specified by:
attributeValuein interfaceXMQElement- Parameters:
name- The attribute name.- Returns:
- The value or null if the attribute does not exist.
-
elements
Returns the element children.- Specified by:
elementsin interfaceXMQElement- Returns:
- A new list of the child elements.
-
element
Returns the first child element with the given name.- Specified by:
elementin interfaceXMQElement- Parameters:
name- The local name.- Returns:
- The element or null.
-
fullName
-