Description |
XMLFind 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>2</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:
-
XMLFind (0, 1, '/order/issued_by', 'name', 0, '', 'John Smith') returns 1.
-
XMLFind (0, 1, '/order/issued_by', 'name', 0, '', 'John') returns 0 because there is no name element with the value John under the /order/issued_by path.
-
XMLFind (0, 1, '/order', 'item', 1, 'cat_num', '1384325456') returns 2.
-
XMLFind (0, 1, '/order', 'item', 1, 'cat_num', '12345') returns 0 because there is no item in the order with a catalog number that equals 12345.
-
XMLFind (0, 1, '/order', 'item', 0, 'price', '99.99') returns 1.
-
XMLFind (0, 1, '/order', 'item', 0, 'amount', '2', 2) returns 2.
|
|
---|