1

I'm developing an application in phone gap. In this i've to parse an xml to get the data and display in my app. Below I've given the XML from which I've to get data.

<Result>
<Art Transaction="event/listAllUsersXml" Success="True"/>
<ExhibitorAndSponsor UserID="60" UserName="Economy Times" UserPhoto="http://www.bestbusinessplaces.com/event/admin/logos/big/100X100.gif" Latitude="" Longitude="" Country="" UserType="SponsorAndExhibitor"/>
<ExhibitorAndSponsor UserID="61" UserName="Cadbury" UserPhoto="http://www.bestbusinessplaces.com/event/admin/logos/big/100X100.gif" Latitude="" Longitude="" Country="Andorra" UserType="SponsorAndExhibitor"/>
<ExhibitorAndSponsor UserID="62" UserName="Pepsi" UserPhoto="http://www.bestbusinessplaces.com/event/admin/logos/big/100X100.gif" Latitude="" Longitude="" Country="" UserType="SponsorAndExhibitor"/>
</Result>

So can anyone tell me how to get the data from the xml string.

Thanks in Advance


function displayData(){
            UserID = (x[i].getElementsByTagName("UserID")[0]);
            UserName = (x[i].getElementsByTagName("UserName")[0]);
            UserType = (x[i].getElementsByTagName("UserType")[0]);
            txt = "UserID: " + UserID + "<br />UserName: " + UserName + "<br />UserType: "+ UserType;
            document.getElementById("showCD").innerHTML = txt;
        }

//

i'm using this code to get the value from the xml. But the value in i've get is nothing(Undefined).

2
  • possible duplicate of XML parsing of a variable string in JavaScript Commented Jun 19, 2012 at 5:43
  • Thanks a lot... I get the solution... In this function i've to use " getattribute("UserId"); " instead of " getElementByTagName("UserId"); " Thank You. Commented Jun 19, 2012 at 6:24

1 Answer 1

1

You should try this:

http://api.jquery.com/jQuery.parseXML/

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.