0

I'm trying to get this value B006PF20EI in this XML

<ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
    <OperationRequest>...</OperationRequest>
    <Items>
        <Request>...</Request>
        <TotalResults>8</TotalResults>
        <TotalPages>1</TotalPages>
        <MoreSearchResultsUrl>...</MoreSearchResultsUrl>
        <Item>
            <ASIN>B006PF20EI</ASIN>

I'm using XPaths like so

public String parseXml(String xmlString){

    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    try {

        DocumentBuilder builder = domFactory.newDocumentBuilder();
        Document dDoc = builder.parse(new InputSource(new StringReader(xmlString)));

        XPath xPath = XPathFactory.newInstance().newXPath();
        //Node node = (Node) xPath.evaluate("/Items/Item/ASIN", dDoc, XPathConstants.NODE);
        //System.out.println(node.getNodeValue());
        String value = xPath.evaluate("/ItemSearchResponse/resp/status", dDoc);
        return value;
    } catch (Exception e) {
        Log.e("MYAPP", "exception", e);
        return null;
    }
}

But it looks like the method is just returning an emptry string

1 Answer 1

1

use the good path:

/ItemSearchResponse/Items/Item/ASIN
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, it's late. Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.