XPath
The XML Plug-In utilizes standard XPath expressions for parsing and delineating XML data.
The plug-in uses a specific subset of the XPath syntax when generating queries for each element and attribute node. Below is a simple XML example and the expressions that would be generated for each node.
Though the expressions generated by the plug-in are specific single node access queries, when running the plug-in you can use any valid XPath expression. In cases where multiple nodes are selected by an expression, every selected item will have its value updated by the associated ModelCenter variable value (in the Plug-In) or the associated value in the configuration file (in the Command Line Tool). See the W3C information page for more information on the full XPath expression syntax.
XML Document Example
1: <?xml version="1.0" encoding="ISO-8859-1"?>
2: <menu>
3: <food meal="breakfast" id="1">
4: <name>Belgian Waffles</name>
5: <price>$5.95</price>
6: <description>Two of our famous Belgian Waffles with plenty of real maple syrup.</description>
7: <calories fromFat="150">650</calories>
8: </food>
9: <food meal="lunch" id="2">
10: <name>Grilled Chicken Sandwich</name>
11: <price>$6.50</price>
12: <description>Grilled chicken on a sesame seed bun, served with tomatoes, lettuce, and onions. Comes with 1 side.</description>
13: <calories fromFat="185">875</calories>
14: </food>
15: <prime:food xmlns:prime="http://example.com/prime_foods" meal="dinner" id="3">
16: <prime:name>Beef Tips</prime:name>
17: <prime:price>$12.95</prime:price>
18: <prime:description>Grilled beef tips cooked to order with brown gravy, onions, and mushrooms. Comes with 2 sides.</prime:description>
19: <prime:calories fromFat="315">1150</prime:calories>
20: </prime:food>
21: </menu>
Generated XPath Expressions
1: The XML declaration. This line is not parsed. If an encoding is specified, the encoding will be preserved on any alteration to the file.
2: /menu[1]
3: /menu[1]/food[1]
/menu[1]/food[1]/@meal
/menu[1]/food[1]/@id
4: /menu[1]/food[1]/name[1]
5: /menu[1]/food[1]/price[1]
6: /menu[1]/food[1]/description[1]
7: /menu[1]/food[1]/calories[1]
/menu[1]/food[1]/@fromFat
8: Element end node. No expression generated.
9: /menu[1]/food[2]
/menu[1]/food[2]/@meal
/menu[1]/food[2]/@id
10: /menu[1]/food[2]/name[1]
11: /menu[1]/food[2]/price[1]
12: /menu[1]/food[2]/description[1]
13: /menu[1]/food[2]/calories[1]
/menu[1]/food[2]/@fromFat
14: Element end node. No expression generated.
15: /menu[1]/prime:food[1]
/menu[1]/prime:food[1]/@meal
/menu[1]/prime:food[1]/@id
16: /menu[1]/prime:food[1]/name[1]
17: /menu[1]/prime:food[1]/price[1]
18: /menu[1]/prime:food[1]/description[1]
19: /menu[1]/prime:food[1]/calories[1]
/menu[1]/prime:food[1]/@fromFat
20: Element end node. No expression generated.
21: Element end node. No expression generated.
Resulting Variable Structure
Name Type Default Value
PlugIn
menu
food
name string Belgian Waffles
price string $5.95
description string Two of our famous Belgian Waffles with plenty of real maple syrup.
calories double 650
calories_attributes
fromFat double 150
food_attributes
meal string breakfast
id double 1
food_2
name string Grilled Chicken Sandwich
price string $6.50
description string Grilled chicken on a sesame seed bun, served with tomatoes, lettuce, and onions. Comes with 1 side.
calories double 875
calories_attributes
fromFat double 185
food_2_attributes
meal string lunch
id double 2
foor_3
name string Beef Tips
price string $12.95
description string Grilled beef tips cooked to order with brown gravy, onions, and mushrooms. Comes with 2 sides.
calories double 1150
calories_attributes
fromFat double 315
food_3_attributes
meal string dinner
id double 3
*PlugIn, menu, food* are groups with sub-variables