Xpath: Supplier "Mother" Id "1"
Xpath: Supplier "Mother" Id "1"
<inventory>
<drink>
</drink>
<snack>
</snack>
</inventory>
Drink is the child of inventory. Lemonade and pop are siblings. Price
and amount are children of lemonade.
2. If we want to find out the supplier of chips.
Inventory/snack/chips@supplier
3. We can also specify the above one like this
Inventory//chips@supplier
4. If we want to get all the prices then
Inventory//price
5. If we want to find the Price of First Lemonade
Inventory/drink/lemonade[1] --Predicates
6. Find the parent of lemonade
Inventory/drink/lemonade/..
7. Find all the children of pop
./inventory/drink/pop/* -- wild card
9. Find all the children in inventory(last generation)
inventory/*/*/*
10. Find all the inventory whose quantity > 15
inventory/*/*[amount >15]
inventory/*/*[amount >15]/..
11. Find lemonades whose quantity >15
inventory/drink/lemonade[amount >15]
inventory/drink/lemonade/amount[. > 15]/..
12. Find the drink whose lemonade quantity > 15
inventory/drink[lemonade/amount > 15] - you can write xpath
inside the [ ]
inventory/drink/lemonade/amount[. > 15]/../..
10. Find all the children of chips and pop( Pipe character to merge two
xmls)
inventory/snack/chips/* | inventory/drink/pop/*
2.
3.
4.
5.
6.
7.