Lars007
asked on
XPath expression listing orders and order totals
Hello,
Attached is a small sample of an Amazon settlement file.
For each <Order> and <Adjustment> node, I need to list AmazonOrderID and the sum of any Amount fields inside, using xpath or similar.
I am using Oxygen XML, but I am open to other tools.
For example //AmazonOrderID gives me:
/SettlementReport[1]/Order [1]/Amazon OrderID[1] - 12342134214
/SettlementReport[1]/Order [2]/Amazon OrderID[1] - 001-2234436-7951404
/SettlementReport[1]/Order [3]/Amazon OrderID[1] - 011-1235465-2323809
/SettlementReport[1]/Adjus tment[1]/A mazonOrder ID[1] - 201-3232197-1108246
/SettlementReport[1]/Adjus tment[2]/A mazonOrder ID[1] - 221-6633333-3111456
sum(//Amount) gives me the sum for all orders:
155.21
What I need is something like this:
/SettlementReport[1]/Order [1]/Amazon OrderID (12342134214) / 42.22
/SettlementReport[1]/Order [2]/Amazon OrderID (001-2234436-7951404) / 32.21
/SettlementReport[1]/Order [3]/Amazon OrderID (011-1235465-2323809) / 44.87
/SettlementReport[1]/Adjus tment[1]/A mazonOrder ID (201-3232197-1108246) / -21.11
/SettlementReport[1]/Adjus tment[2]/A mazonOrder ID (221-6633333-3111456) / - 31.12
or simply the order id and Amount totals:
12342134214, 42.22
001-2234436-7951404, 32.21
and so forth...
What I am trying to do is to track down why a settlement does not balance with another source, so I need an efficient way to query the settlement XML file.
Suggestions of other efficient tools / methods for this are welcome.
Thanks.
test.xml
Attached is a small sample of an Amazon settlement file.
For each <Order> and <Adjustment> node, I need to list AmazonOrderID and the sum of any Amount fields inside, using xpath or similar.
I am using Oxygen XML, but I am open to other tools.
For example //AmazonOrderID gives me:
/SettlementReport[1]/Order
/SettlementReport[1]/Order
/SettlementReport[1]/Order
/SettlementReport[1]/Adjus
/SettlementReport[1]/Adjus
sum(//Amount) gives me the sum for all orders:
155.21
What I need is something like this:
/SettlementReport[1]/Order
/SettlementReport[1]/Order
/SettlementReport[1]/Order
/SettlementReport[1]/Adjus
/SettlementReport[1]/Adjus
or simply the order id and Amount totals:
12342134214, 42.22
001-2234436-7951404, 32.21
and so forth...
What I am trying to do is to track down why a settlement does not balance with another source, so I need an efficient way to query the settlement XML file.
Suggestions of other efficient tools / methods for this are welcome.
Thanks.
test.xml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note that I have different totals than you have (likely because I should exclude some of the values... but than just change the XPath in the sum
ASKER
That's a great way to do it, thanks!
I have not yet bought an XML / XSLT tool, but I quite like the Oxygen tool I am evaluating so far. But they are not cheap, so I want to make sure I get the right tool for this kind of analysis. Are there other tools that you recommend that I look into in addition to Oxygen? It needs to have an XSLT debugger, XPath query tool, etc.
I have not yet bought an XML / XSLT tool, but I quite like the Oxygen tool I am evaluating so far. But they are not cheap, so I want to make sure I get the right tool for this kind of analysis. Are there other tools that you recommend that I look into in addition to Oxygen? It needs to have an XSLT debugger, XPath query tool, etc.
For XPath and XSLT, Oxygen simply is teh best tool
You have Saxon bundled in, you have XPath 1 and 2 evaluation,
you can debug against a number of XSLT processors,
and you get all an XML developer need ... a whole bunch of utility tools,
great workbench it is (and I use a number of different tools for various reasons)
Note that Oxygen also has a splendid user support and forum
You have Saxon bundled in, you have XPath 1 and 2 evaluation,
you can debug against a number of XSLT processors,
and you get all an XML developer need ... a whole bunch of utility tools,
great workbench it is (and I use a number of different tools for various reasons)
Note that Oxygen also has a splendid user support and forum
ASKER
A+!
cheers