<invoice>
<obs>
<ob>
<code>ABC</code>
</ob>
<ob>
<code>123</code>
</ob>
</obs>
</invoice>
<invoice>
<obs>
<ob>
<code>DEF</code>
</ob>
</obs>
</invoice>
</invoices>
Ok , my question is , I have that xml , which will come to me from external system ,it can have large number of 'invoice' nodes and one 'invoice' node can have large number of 'code' nodes. I want to read the 'code' nodes of all 'invoice' nodes and save them in an array like this : invoice[1].code[1]=ABC invoice[1].code[2]=123 invoice[2].code[1]=DEF . How to do this using XPathExpression in JAVA. Below is my xpath expression which is not working.
expr = xpath.compile("//invoices/invoice/obs/ob/code/text()");
Please give a general answer in case number of 'invoice' nodes and 'code' nodes are high