0

In my main activity I have this call:

InputStream stream = http_conn.getInputStream();
            ParseXML.Login(stream);

I know the input stream is working as I can create a buffered reader, creating a string that I can send to the UI. The issue is this reports the entire XML document that is being returned to me.

Within my ParseXML class Login method, I have the following:

DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(stream);
        doc.getDocumentElement().normalize();

So far so good, I think? I am new to using parsers, but basically the layout of my XML document is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="http://www.xxx.com/asmx">TOKEN HERE</string>

I have seen examples in which you can retrieve various items from deeper with an XML file, as per the example here: http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/

I'm not only new to XML parsers but new to java as well, I just can't figure out how to pull that string out of the XML document!

Thanks

1 Answer 1

1

I don't know if I'm understanding but if you want to get only TOKEN HERE try doc.getDocumentElement().getTextContent()

Sign up to request clarification or add additional context in comments.

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.