xmlChildOf FunctionReturns a specific child XML element of another XML element. SyntaxxmlEl = xmlChildOf(el, tagName, index); Parameters
ReturnsReturns the specified XML element, or a null reference if it does not exist. Example 1
<CUSTOM_FOO>
<FOO>
<BAR>Inside Bar</BAR>
</FOO>
</CUSTOM_FOO>fooEl = xmlChildOf(xmlLocData, "FOO", 0); barEl = xmlChildOf(fooEl, "BAR", 0); spanBar.innerText = barEl.text; The HTML element spanBar will display Inside Bar. Example 2<CUSTOM_FOO> <FOO>Inside Foo 1</FOO> <FOO>Inside Foo 2</FOO> <FOO>Inside Foo 3</FOO> </CUSTOM_FOO>
foo = xmlChildOf(xmlLocData, "FOO", 0);
spanFoo.insertAdjacentText("beforeEnd",
foo.text + "... ");
foo = xmlChildOf(xmlLocData, "FOO", 1);
spanFoo.insertAdjacentText("beforeEnd",
foo.text + "... ");
foo = xmlChildOf(xmlLocData, "FOO", 2);
spanFoo.insertAdjacentText("beforeEnd",
foo.text + "... ");
for(i = 0;
i < xmlNumChildOf(xmlLocData, "FOO");
i++)
{
foo = xmlChildOf(xmlLocData, "FOO", i);
spanFoo.insertAdjacentText("beforeEnd",
foo.text + "... ");
}The HTML element spanFoo will contain the following: Both script fragments achieve the same result. |
