Function: xmlobj

Syntax

xmlobj( <xmlfile> {,<num>} )

Type

component

Returns

Creates an instance of an XML object for subsequent analysis. The function returns the value null if the object cannot be created.
The component corresponds to an XML element within the XML data.

The created object may be examined to determine the data hierarchy and element values.

Elements within the hierarchy may be retrieved as further xml components via available component methods.

Parameters

Examples

component myxml = xmlobj('http://www.monkeys.com/livefeed.xml')

Notes

The following property members are available on an xml component:

Component property Property type Description
.array_index numeric The array index of the xml element relative to its parent element.
Indices are 1-based.
.attribute_names string[ ] The names of all attributes associated with this element.
.child_names string[ ] The names of all unique element children supplied with the xml element.
.file string The file name (or URL) associated with this XML object.
.name string The element (tag) name of this element.
.parent component The parent element of this element as an xml component.
If this element is already the top-level element the value is null.
.tag string Element tag name.
.tvalue string The text value of this element.

The following function members are available on an xml component:

Component function Returned type Description
.child(<string>{,<num>}) component[ ] All child elements named <string>, or
the <num>th child element named <string>, or
an empty component array if the element has no such child element.
.child_alength(<string>) numeric The number of child elements with the name <string>.
.child_tvalue(<string>{,<num>}) string The text value of the <num>th (or first) child element named <string>,
or an empty string if the element has no such child element.
.decode(<ident>) numeric Decode the xml data of this element (and child elements if necessary) into the identifier <ident>.
A value of 0 is returned when successful, or non-zero on failure.
.find(<wild>{,<recurse>}) component[ ] Find all child elements whose name satisfies the wild string <wild>.
If <recurse> is non-zero, child elements of child elements are searched recursively.
.get_attribute(<string>{,<string2>}) string The text value of the attribute <string>,
or the value of <string> if the element has no such attribute.
.has_attribute(<string>) numeric The value 1 if the attribute <string> exists, or 0 if it doesn't.