PDA

View Full Version : small problem


nagsline
02-08-2006, 10:12 AM
Hi
how can i count no.of individual records as well as total records in an xml file before starting my actual process for example my xml file like this.

<employee>
<emp name = "a" desg = "programmer" ecode = "101" />
<emp name = "b" desg = "Designer" ecode = "102" />
<emp name = "a" desg = "Tester" ecode = "103" />
<emp name = "a" desg = "Tester" ecode = "104" />
<emp name = "a" desg = "Designer" ecode = "105" />
<emp name = "a" desg = "Tester" ecode = "106" />
<emp name = "a" desg = "Designer" ecode = "107" />
<emp name = "a" desg = "programmer" ecode = "108" />
<emp name = "a" desg = "Designer" ecode = "109" />
<emp name = "a" desg = "programmer" ecode = "110" />
<emp name = "a" desg = "Tester" ecode = "111" />
<emp name = "a" desg = "Tester" ecode = "112" />
<emp name = "a" desg = "programmer" ecode = "113" />
</employee>
then how can i count no.of programmers , Testers and Designers and also total no.of records.
Another problem is how can i move freequently from one record to another (not only next or previous , just like very first record or very last record or anyother record)
Thanx
Jai...

jcmaxx
02-08-2006, 03:59 PM
then how can i count no.of programmers , Testers and Designers and also total no.of records.
According to chapter 32 of the Developer's Guide, you can use the the last() function. I haven't actually tried it but it seems like the following would work for Testers:
myData:/employee/emp[@desg = 'Tester']/last()
Programmers and designers would work the same way. You could either add up all the values or use the last() method on the employee tag for totals.

Another problem is how can i move freequently from one record to another (not only next or previous , just like very first record or very last record or anyother record)
Look at the documentation for LzDataElement, LzDataNode, LzDataPath and LzDataPointer objects. They have numerous methods which could be used from javascript to move through the dataset. LzDataElement, for instance, has the getElementsByTagName() method which returns an array of child elements with a specific tag name.

Hope this helps.