ar/xmlNodes

This object mimicks an array and is used to contain a list of nodes, either as a result from a search, e.g. from getElementsByTagName() or directly created using ar_xml::nodes() or the childNodes property of an element.

An ar_xmlNodes object can be iterated over, and accessed and counted, just like any normal array. However some PHP methods require a real array as input. In that case you must manually cast the object to an array first. e.g:

<pinp>
$list = array_merge( $list, (array) $ul->li );
</pinp>

The ar_xmlNodes object implements all the methods of ar_xmlElement. (Note: The method getElementById() was missing in Ariadne upto and including 2.7.3. )

It has the following properties:

(array) attributes (Readonly.) A list of attributes to set on each child node. Will be re-applied whenever the ar_xmlNodes object is cast to string. Do not change directly, use setAttribute() instead.
(object) childNodes Readonly. A reference to itself.
(bool) isDocumentFragment Whether or not this object is used as a document fragment. False when the list is a result of a search or it has a parentNode.
(object) firstChild Readonly. A reference to the first child node, if available.
(object) lastChild Readonly. A reference to the last child node, if available.
(mixed) nodeValue An array of nodeValues of its childNodes, or if there is only one childNode, the nodeValue of that childNode.
(object) parentNode (Readonly.) A reference to the parent node, if available. Do not change directly, use the proper method, e.g. appendChild(), insertBefore(), etc. Or you can assign a list to the childNodes property of an element.

In addition you can access child nodes by their tag names, e.g.:

<pinp>
$list = ar_xml::nodes(
$x->el('a', 'an a'),
$x->el('a', 'another a'),
$x->el('b', 'a b'),
$x->el('a', 'last a')
);
$list->a->setAttribute('class', 'a');
$list->a[1]->setAttribute('class', 'a2');
echo $list;
</pinp>

Results in:

<a class="a">an a</a>
<a class="a2">another a</a>
<b>a b</b>
<a class="a">last a</a>