1

My XML Feed is at http://tinyurl.com/6wc6fel

I am using following code to read the XML

<script type="text/javascript">
    $(document).ready(function () {

          $.get("read.xml", function (data) {            
            alert('Load was performed.');
        });

    });

 </script>

Since its nested, I want to display folllwing information of the < Hotel > Tag

a) StayDateRange(Start, End)
b) In tag read HotelName,Location
c) Address1, Address2
d) In tag read Url
e) In tag read HotelFrontImage Url
f) In tag NumberOfRooms>>Description

and so on.. how do i do it ?

1 Answer 1

1

You can use standard jQuery methods to traverse the xml. for example:

    $.get("read.xml", function (data) {   
        //this gets the attribute start from the tag StayDateRange
        $(data).find('Hotel').find('StayDateRange').attr('Start');
    });
Sign up to request clarification or add additional context in comments.

15 Comments

i would suggest parsing xml with parseXML api.jquery.com/jQuery.parseXML
@3nigma jquery should gess the fact that it's an xml and do that for you, after all $.get is a wrapper around $.ajax
@3nigma by default if you don't specify a datatype it defaults to intelligent guess api.jquery.com/jquery.get
@NicolaPeluchetti I tried to use your code at tinyurl.com/7sfedsy but its not showing anything can you help with jsfiddle
the attribute is Start not start try $(data).find('hotel').find('StayDateRange').attr('Start'); that cant be replicated on jsfiddle because cross domain requests are not allowed
|

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.