0

I have an xml where the parent and child node has same name . The xml is

<response>
<cmd>abcr</cmd>
<success>1</success>
<response>
<user_login>....</user_login>
<user_email>..</user_email>
    </response>
<errCode>0</errCode>
<errText/>
</response>

ie i have a response within response . I need to extract the value of userlogin

i have code

doc = parser.getDomElement(xml);
            NodeList responseList = doc.getElementsByTagName("response");
            Element response = (Element) responseList.item(0);
            String name = parser.getValue(response, "user_login");

It is not working correctly . What should i change to make it correct. please help

1
  • You need to take and maintain flag value. Commented Sep 17, 2013 at 8:19

2 Answers 2

1

Try Below code:

NodeList nodeList = doc.getElementsByTagName("user_login");
String name = nodeList.item(0).getChildNodes().item(0).getNodeValue();
Sign up to request clarification or add additional context in comments.

Comments

0

Answered my own question...

xmlMessagesCount = xml.documentElement.getElementsByTagName("messages").item(0).getChildNodes().length;

Comments

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.