So I have an XML file here, and I want to get a value from it using XPath. The file in question is an XML file in a zip that you can download here:
I believe that it's valid XML.
My current goal is to parse out the last (newest) LMP_PRC value in the document.
My current code looks like this and returns an empty string every time:
XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); XPathExpression expr = xpath.compile("//m:OASISReport/m:MessagePayload/m:RTO/m:REPORT_ITEM[3]/m:REPORT_DATA[/m:DATA_ITEM='LMP_PRC'][last()]/m:VALUE/text()") ; String result = (String) expr.evaluate(doc, XPathConstants.STRING); The m:REPORT_ITEM[3] has been an area of confusion for me so I've tried it with just about every number and have had no luck with it.