My intention is to "select the data where container number is equals to input data" (kind of search functionality). I am facing an issue when I am trying to retrieve the data, with a problem at where condition:
d:goodsShipments/d:consignment/d:transportEquipment/d:id/text()
Here I am getting multiple data. I don't know how to iterate it in the where condition.
My query is:
My source XML is:
How i can select all the declaration where sealId is 5678? how deal with the where condition in this case?
You can use the below query to iterate and get the id's from container component..
You have multiple containers per consignment, and you're filtering based on LRN after extracting that from the raw XML; so you need to use nested XMLTable objects. The first one gets the data from the declaration and extracts the consignments as a sub-XMLType. That is then passed to the second XMLTable which extracts the container information.
With your (updated) sample XML, that produces:
Hopefully that is what you want to see.
Quick SQL Fiddle demo.
You could also use a more complicated XPath to keep it within a single XMLTable, but I think this is clearer.