This article I summarize, how to use XPath and related technology to query and process XML data documents
1. First, take a look at the sample data
<?xml version= "1.0" encoding= "Utf-8"?> <Orders><!--All orders--> <order "1" orderid= " 2008-12-17 "><!--an order--> <OrderItems><!--Details of the order--> <Item> <productid>1</product id> <Quantity>2.0</Quantity> <UnitPrice>25.5</UnitPrice> </Item> <ITEM&G
T
<ProductID>2</ProductID> <Quantity>2.0</Quantity> <UnitPrice>5.5</UnitPrice> </Item> <Item> <ProductID>3</ProductID> <Quantity>29.0</Quantity> &L T unitprice>300.5</unitprice> </Item> </OrderItems> </Order> <order orderid= "2" Orderda Te= "2009-01-01" > <OrderItems> <Item> <ProductID>1</ProductID> <quantity>2.0& lt;/quantity> <UnitPrice>25.5</UnitPrice> </Item> </OrderItems> </Order> </o Rders>
This is a typical order data. Orders can have one or more order, each with two attributes: Orderid,orderdate, and each order has one or more OrderItem