I would like to extract a single value from a large xml file (part of a much larger xml project that I’m working on)
So the xml structure is like this:
<m:Report>
<m:Messages>
<m:report_type>
<m:Report_Data> (last value)
<m:Data_Item> (must be specific type)
<m:Value> (want this)
After this all tags close properly
So right xpath query looks something like this:
XPathExpression expr = x.compile("//m:Report/m:Messages/m:Report_type/m:Report_Data[m:Data_Iten='PRICE'][last()]/m:Value/text()") ;
I’m not having much luck with this query, where am I going wrong?
There are simply errors in your query.
Report_typeshould bereport_typeandData_Itenshould beData_Item:Assuming that you have a
Data_Itemin your input data withPRICE, then this should get you the<m:Value>.