I have a following XML:
<data>
<DataType1>
<val1/>
<val2/>
</DataType1>
<DataType2>
<val21/>
<val22/>
<RetrieveThis1>test1</RetrieveThis1>
<RetrieveThis2>test2</RetrieveThis2>
<RetrieveThis3>test3</RetrieveThis3>
</DataType2>
</data>
I need to retrive values test1, test2 and test3 in java. I am trying to use xPath queries as follows:
String test1Value = xpath.compile("/data/DataType2/RetrieveThis1").evaluate(inputXML);
String test2Value = xpath.compile("/data/DataType2/RetrieveThis2").evaluate(inputXML);
String test3Value = xpath.compile("/data/DataType2/RetrieveThis3").evaluate(inputXML);
It is not giving the result. Could you please suggest if XPathExpresstion I am passing in compile query is correct.
Thank you so much in advance.
Aucun commentaire:
Enregistrer un commentaire