Libraries anvil xml Node

class Node
extends anvil.lang.object
Node in XML tree.

Constants

constant TYPE_ATTRIBUTE

constant TYPE_CDATA_SECTION

constant TYPE_COMMENT

constant TYPE_DOCUMENT

constant TYPE_DOCUMENT_FRAGMENT

constant TYPE_DOCUMENT_TYPE

constant TYPE_ELEMENT

constant TYPE_ENTITY

constant TYPE_ENTITY_REFERENCE

constant TYPE_NOTATION

constant TYPE_PROCESSING_INSTRUCTION

constant TYPE_TEXT


Methods

Node addCDATA(string cdata)

Node addComment(string comment)

Node addElement(string nodeName)
Node addElement(string nodeName, attrs)

Node addElementNS(string nsURI, string qName)
Node addElementNS(string nsURI, string qName, attrs)

Node addPI(string target, string data)
Add a processing instruction inside current node.

Node addText(string text)

Node appendChild(Node newNode)

Node createCDATA(string cdata)

Node createComment(string comment)

Node createDocumentFragment()

createElement(name, *attrs)

Node createElementNS(string name)
Node createElementNS(string name, array attrs)

Node createPI(string target, string data)

Node createRef(string name)

Node createText(string text)

string getAttribute(string name)
string getAttribute(string name, string namespaceURI)
Returns the given attribute from this node.
Returns The value of attribute, null if node is not an element, empty string if attribute does not exist, or does not have any value - specified or default.

array getAttributes()
Returns the attributes of this node.
Returns array of attributes for this node. Attributes are mapped into array with their respective names.

list getChildNodes()
Returns list of child nodes of this node.
Returns array of children for this node. Returns empty list if node does not have any children.

list getChildren(name)
Returns list of child nodes with given name
Returns array of children for this node. Returns empty list if node does not have any children named name.

getChildText(name, *nsURI)

getChildTextsTrim(name, *nsURI)

getChildTextTrim(name, *nsURI)

string getData()
Returns the data of instruction node.
Returns data of instruction node

Node getDocument()
Returns the owner document of this node.
Returns the document where this node belongs to, returns null is this node is already document node.

Node getDocumentType()
Return the document type of document to which this node belongs to.
Returns document type of document node

array getEntities()
Return the array of entities from document type node.
Returns array of entities of document type node

Node getFirstChild()
Node getFirstChild(name)
Node getFirstChild(name, namespaceURI)
Returns first child node.
Returns first child node, or null if node doesn't have any children

string getLocalName()
Return localname, without namespace prefix (if any)
Returns local name of node

string getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
Returns namespace uri

Node getNextSibling()
Returns the next sibling of this node.
Returns next sibling or null if there is no such node. Next sibling is child of this node's parent that is immediately next to this node.

string getNodeName()
Returns the name of this node (with prefix, if any).
Returns the name of node

int getNodeType()
Returns the type of this node.
Returns the type of node as an integer constant

string getNodeTypeName()
Returns the type of this node as string, which is one of
Returns type of node

string getNodeValue()
Returns the value of this node.
Returns the value of node

array getNotations()
Return the array of notations from document type node.
Returns array of notations of document type node

Node getParentNode()
Returns the parent node of this node.
Returns the parent node of this node, returns null if this node does not have a parent.

string getPrefix()
The namespace prefix of this node, or null if it is unspecified.
Returns namespace prefix

Node getPreviousSibling()
Returns the previous sibling of this node.
Returns next sibling or null if there is no such node. Previous sibling is child of this node's parent that is immediately next to this node.

string getPublicId()
Returns the public id of this node.
Returns public id of document type, entity and notation nodes

Node getRoot()
Gets the root element.
Returns the root node of document where this node belongs to

string getSystemId()
Returns the system id of this node.
Returns system id of document type, entity and notation nodes

string getTarget()
Returns the target of instruction node.
Returns target of instruction node

string getText()
This returns the textual content directly held under this element. This will include all text within this single element, including whitespace and CDATA sections if they exist. It's essentially the concatenation of all Text and CDATA nodes returned by getContent(). The call does not recurse into child elements. If no textual value exists for the element, null is returned.

list getTextsTrim()
This returns the textual content of this element with all surrounding whitespace removed. Trimmed values are returned as list of string. Zero length text elements are not returned. If no textual value exists for the element, or if only whitespace exists, empty list is returned. Example. ' foo bar
some text
' would return ('foo bar', 'som text') Note. only surrounding whitespace is returned!

string getTextTrim()
This returns the textual content of this element with all surrounding whitespace removed. If no textual value exists for the element, or if only whitespace exists, null is returned.

string getXML()
Gets the contained tree in XML presentation.

boolean hasAttributes()
Checks if this node has attributes.
Returns true if node has attributes

boolean hasChildNodes()
Checks if this node has children.
Returns true if node has children

Node insertBefore(Node newNode, Node refNode)

Node output(OutputStream output)
Node output(OutputStream output, String encoding)
Node output(OutputStream output, String encoding, boolean indent)
Outputs the contained tree in XML presentation to given output stream.

Node removeChildren()
Node removeChildren(name)
Node removeChildren(name, namespaceURI)
Removes all child nodes with given name/namespaceURI, or all children if name isn't given.
Returns returns this node

Node replaceChild(Node newNode, Node oldNode)

iterator select(string xpath)

list selectMultipleText(string xpath)

Node selectSingle(string xpath)

string selectSingleText(string xpath)

setAttribute(name, value, *nsURI)


Operators

Returns the number of childs nodes of this node.















Returns the iterator of child nodes of this node.