Banana.Xml.XmlElement

This documentation is outdated

The most complete and up-to-date documentation is the one of Banana Accounting Plus: Try it now

In this article

The XmlElement class represent an Xml element. See Banana.Xml for an example.

Since: Banana Accounting 8.0.5

Properties

nodeName

The read only property nodeName returns the node name of the xml element.

parent

The read only property parent returns the parent of this Xml element as a Banana.Xml.XmlElment object. If this is the root element, it return null.

text

The read only property text returns the text of this Xml element and their childs.

value

This is a synomin of the property text.

Methods

attibute(name [, defaultValue])

Returns the value of the attribute with the specified name as a string. If no attibute with the specified name is found, the defaultValue or an empty string is returned.

attibuteNS(ns, name [, defaultValue])

Returns the value of the attribute with the specified name and namespace as a string. If no attibute with the specified name is found, the defaultValue or an empty string is returned.

hasAttribute(name)

Returns true is the attribute with the specified name exists.

hasAttributeNS(ns, name)

Returns true is the attribute with the specified name and namespace exists.

firstChildElement([name])

Returns the first child element with the specified name if name is non-empty, otherwise it returns the first child element. Returns null if no such child exists.

var bookNode = xmlRoot.firstChildElement('Book');  // First book
while (bookNode) { 
   // For each book in the library
   var title = xmlFile.firstChildElement('Title').text();
   bookNode = bookNode.nextSiblingElement('Book');  // Next book
} 

hasChildElements([name])

Returns true if this element contains one or mode elemets with the specified name.

lastChildElement([name])

Returns the last child element with the specified name if name is non-empty, otherwise it returns the last child element. Returns null if no such child exists.

elementsByTagName(name)

Returns an array containing all descendants of this element with the specified name.

nextSiblingElement([name])

Returns the next sibling element with the specified name if name is non-empty, otherwise returns any next sibling element. Returns null if no such sibling exists.

previousSiblingElement([name])

Returns the previous sibling element with the specified name if name is non-empty, otherwise returns any previous sibling element. Returns null if no such sibling exists.

Share this article: Twitter | Facebook | LinkedIn | Email