XML parsing problem

Posted by Albinoswordfish on Stack Overflow See other posts from Stack Overflow or by Albinoswordfish
Published on 2010-03-26T17:13:08Z Indexed on 2010/03/26 17:33 UTC
Read the original article Hit count: 202

Filed under:
|
|

I'm having this strange XML parsing problem.

I have this XML string I'm trying to parse

<?xml version="1.0"?>
<response status="success">
<lot>32342</lot>
</response>

I'm using XPath with Java in order to do this. I'm using the Xpath expression "/response/@status" to find the text "success". However whenever I evaluate this expression I get an empty string.

However I am able to successfully parse this string using "/response/@type"

<?xml version="1.0"?>
<response type="success">
<lot>32342</lot>
</response>

So why would simply changing the name of the attribute change the return string to nothing?

is = new InputSource(testWOcreateStrGood); 
xPathexpressionSuccess = xPath.compile("/response/@status");
responseStr = xPathexpressionSuccess.evaluate(is);

reponseStr is the string I posted earlier with the "status" attribute

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml