TQS Home
Trivia Quiz Shell Version 2.8 Now Available!Bot Productions Home
TQS 2.0

Back to Reference

xmlNumChildOf Function

Returns the number of child XML elements that have a given element tag name.

Syntax
value = xmlNumChildOf(el, tagName);
Parameters

el
XML parent object.
tagName
The element tag name.
Returns

Returns the number of child elements of the specified name; zero if none exist.

Example 1
<CUSTOM_FOO>
  <FOOHOLDER>
    <FOO BAR="Foo 1"/>
    <FOO BAR="Foo 1"/>
  </FOOHOLDER>
</CUSTOM_FOO>
numFoos = xmlNumChildOf(xmlChildOf
  (xmlLocData, "FOOHOLDER", 0), "FOO", 0);

The variable numFoos will equal 2.

Example 2
<CUSTOM_FOO>
  <FOO>Inside Foo 1</FOO>
  <FOO>Inside Foo 2</FOO>
  <FOO>Inside Foo 3</FOO>
</CUSTOM_FOO>
for(i = 0;
  i &lt; xmlNumChildOf(xmlLocData, "FOO");
  i++)
{
  foo = xmlChildOf(xmlLocData, "FOO", i);
  spanFoo.insertAdjacentText("beforeEnd",
    foo.text + "... ");
}

The HTML element spanFoo will contain the following:
Inside Foo 1... Inside Foo 2... Inside Foo 3...

©2020 Bot Productions. All rights reserved.Last Updated: September 9, 2007