簡體   English   中英

使用Jquery讀取XML中的嵌套節點

[英]Read nested nodes in XML using Jquery

我的XML Feed位於http://tinyurl.com/6wc6fel

我正在使用以下代碼讀取XML

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

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

    });

 </script>

由於它是嵌套的,所以我想顯示<Hotel>標簽的以下信息

a)StayDateRange(開始,結束)
b)在標簽中讀取HotelName,Location
c)地址1,地址2
d)在標簽讀取網址
e)在標簽中讀取HotelFrontImage Url
f)在標簽NumberOfRooms >>描述中

等等..我該怎么做?

您可以使用標准的jQuery方法遍歷xml。 例如:

    $.get("read.xml", function (data) {   
        //this gets the attribute start from the tag StayDateRange
        $(data).find('Hotel').find('StayDateRange').attr('Start');
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM