KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Counting the number of specified child elements in XML code
PRODUCT: 4D | VERSION: 2004.2 | PLATFORM: Mac & Win
Published On: November 20, 2005

You can count the number of child elements you specify using the DOM Count Elements command. You specify the name of the child element you want to count that is dependent to the parent element that is designated by the element reference you pass. For instance, let us say you have the XML structure below and you want to count the element "c1":



Hello1


Hello2




You can then perform the code below which should return the number of "c1" elements:
$ref1:=DOM Parse XML source("C://test.xml")
$elementRef:=DOM Find XML element($ref1;"/a/b")
$numElements:=DOM Count XML elements($elementRef;"c1")