Whitebeam Template Reference Documentation

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Template Reference Documentation

rb.XmlTag Object Description
(XmlTag Template)

The XmlTag class is used to represent a single XML tag. The XmlTag class inherits all the behaviour of XmlGeneric and adds a number of additional methods - documented below.

The elements of the XML tag are represented as follows:

XmlTag - Constuctor

Within JavaScript you can manually create a new XML tag - but when you do so it MUST be attached within an existing XML tree. To do this the parent for the tag being created must be provided as a parameter to the constructor. The constructor takes two parameters (the second optional).

var newTag = new XmlTag(XmlTag parent, [[name], index]);

That is - to create a new XML tag - you MUST specify it's parent, and you may optionally specify the name of the tag. If you don't specify a name then the name may be specified by subsequently setting the 'name' property of the resulting tag.

XML Attributes

The XmlTag object has a property called 'attributes'. This itself is a JavaScript object with a number of properties - each representing an XML attribute of this tag. The name of the property is the name of the XML attribute. So - for example consider the following tag:

<aTag name="fred" age="22" id="43AB3" return="average"/>

In this example - the coresponding XmlTag object will have the following properties:

PropertyValue
tag.attribute.name"fred"
tag.attribute.age"22"
tag.attribute.id"43AB3"
tag.attribute.return"average"
Some attribute names may not be legal JavaScript property names - or may be reserved words. In this case you access the properties with the subscript mechanism. So in the example above - the 'return' property cannot be accessed as tag.attributes.return, because this is a reserved word in JavaScript. Instead it would be accessed in code as tag.attributes["return"].

The XmlTag object itself is similar to an array (it is not a JavaScript Array!). The numeric properties of the object represent the direct child elements of the XmlTag. So 'tag[0]' represents the first child element - which could be another tag, a text element or something else.

Methods

rb.XmlTag.bodytext() Text representation of the XML subtree. ADVANCED.
rb.XmlTag.text() Text representation of the XML subtree. ADVANCED.
rb.XmlTag.deleteAt() Remove an XML element at a specific index.
rb.XmlTag.mark() Mark the XmlTag with a specific name.
rb.XmlTag.find() Search for named XML tags.
rb.XmlTag.findId() Search for XML tags with a specific ID.
rb.XmlTag.whichIndex() Return index of child XML element.

Object Properties

Name Type/Value Range/Length Description
namestring  Required. The name of the XML tag represented by this XmlTag JavaScript object. So for example <h1> - the name property would have the string value of 'h1'
lengthnumber  Required. The number of child elements of this tag. This can be used to loop through the children.
innerXMLnumber  Required.

The computed contained XML held within this tag. This string will be empty unless that tag has been executed.

Applications may set the value of innerXML to a string containing valid XML. In this case Whitebeam will parse the XML and build an element tree that will then replace all the current contents of the specified XmlTag.

In many ways this property is analogous to the client-side HtmlElement.innerHTML, although note that setting the innerXML will not change the output text value of the tag to reflect the contents. To do this the node must be re-executed.

innerHTMLnumber  Required.

Synonymn for node.innerXML for those familiar with client-side Javascript.

parentstruct XmlTagsee definition Required. A reference to the XmlTag that is the parent of this XmlTag. The only element not to have a parent is the root tag in the parser (parser.root).

Whitebeam release 1.3.36
(loadtime : 12ms)