Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML count node
If I want to count the amount of <Pair> nodes within <FolderPairs> in the below example, how do I use the 'Count()' (If applicable in this example). I got 'Count' from the helpfile:

Select All      Help
Gets the number of nodes in XML, including attributes.

Below I used .len and it returns 2 which is seems correct as <FolderPairs> has 2 x child nodes: <Pair>...</Pair>
Is this correct? in other words: Can I use .len If I specified x.Path correctly?:
FreeFileSync/MainConfig/FolderPairs/* (see below in example).

To avoid confusion, I want to count how many times <Pair>...</Pair> occurs.

Macro xml - count nodes - example 1
Select All      Help
;This example should output the <Pair> count under the parentnode <FolderPairs>

ARRAY(IXmlNode) a
str xml=
;<?xml version="1.0" encoding="UTF-8"?>
;<FreeFileSync XmlFormat="6" XmlType="GUI">

IXml x._create
IXmlNode e

int i
e=x.Path("FreeFileSync/MainConfig/FolderPairs/*" a 1)
out a.len ;; Using '.len' to count the CHILD nodes from '<FolderPairs>'
a.len is correct.
Thank you!

Forum Jump:

Users browsing this thread: 1 Guest(s)