I am new to XML parsing and Java. I am trying to parse an xml using XPATH. The XML looks like this
<Root>
<AL1>
<AL1.1>1</AL1.1>
<AL1.2>1</AL1.2>
<AL1.3>
<CX1.1>Bala</CX1.1>
</AL1.1>
<AL1>
<AL1>
<AL1.1>2</AL1.1>
<AL1.2>1</AL1.2>
<AL1.3>
<CX1.1>Bala1</CX1.1>
</AL1.1>
<AL1>
<AL1>
<AL1.1>3</AL1.1>
<AL1.2>1</AL1.2>
<AL1.3>
<CX1.1>Bala2</CX1.1>
</AL1.1>
<AL1>
</Root>
I framed the XPATH like this for getting CX1.1 value /AL1/AL1.3/CX1.1/text(). So far I am able to get only the first occurrence if CX1.1.
XPathExpression expr = xpath.compile("/AL1/AL1.3/CX1.1/text()");
result = (String) expr.evaluate(doc.XPathConstants.STRING);
Could you guys please let me know of a way to get all the different values of CX1.1 in a List using XPATH. Any help is greatly appreciated. Thank you.