Kiran
Kiran

Reputation: 345

Parse xml in titanium

I have response data from a server. I need to extract the resultant content value from the XML.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <Response xmlns="http://tempuri.org/">
            <Result>Token1234567890</Result>
        </Response>
    </soap:Body>
</soap:Envelope>

I tried with getElementsByTagName('Response').text;

How can I get Element content for the Result which is Token1234567890?

Upvotes: 0

Views: 129

Answers (2)

Kiran
Kiran

Reputation: 345

var tokenData = responseData.getElementsByTagName('Response').item(0).text;

If i am using above code its working fine!

Upvotes: 0

imulsion
imulsion

Reputation: 9040

Replace

getElementsByTagName('Response').text;

With

getElementsByTagName('Response').innerXML;

It's an XML document.

Upvotes: 2

Related Questions