XMLCnt Example (Magic xpa 4.x)
<?xml version="1.0"?>
<order id="123">
<issued_by>
<name>John Smith</name>
<address>
<street>Somewhere</street>
<city>Nowhere</city>
</address>
</issued_by>
<item cat_num="2145451544">
<price>99.99</price>
<amount>2</amount>
</item>
<item cat_num="1384325456">
<price>19.99</price>
<amount>10</amount>
</item>
</order>
Given that the XML above is saved into the file C:\myxml.xml, and that the current task's first I/O device points to an XML file, the following expressions apply:
-
XMLCnt (0, 1, '/order/issued_by/name') returns 1.
-
XMLCnt (0, 1, '/order/send_to/name') returns 0, since there is no send_to element in the order.
-
XMLCnt (0, 1, '/order/item') returns 2.
-
XMLCnt (0, 1, '/order/item[2]', 'cat_num') returns 1.