我有一個鏈接jQuery的 - 如何從一個網頁,其中顯示XML數據
http://selenium-release.storage.googleapis.com/
當我直接在瀏覽器中打開它顯示XML輸出中提取內容。
任何人都可以幫助我如何使用jquery ajax從該xml獲取所有"Contents"
標記元素的數據。下面
是我的代碼,我已經試過,但它不是爲我工作
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("#dvContent").append("<ul></ul>");
$.ajax({
type: "GET",
url: "http://selenium-release.storage.googleapis.com/",
dataType: "xml",
success: function(xml){
$(xml).find('Contents').each(function(){
var key = $(this).find('Key').text();
var lastmod = $(this).find('LastModified').text();
$("<li></li>").html(key + ", " + lastmod).appendTo("#dvContent ul");
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
});
</script>
<style type="text/css">
body
{
font-family : Arial;
font-size : 10pt;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="dvContent">
dfsdfs
</div>
</form>
</body>
</html>
您可以分析你的XML從遠程腳本使用'jQuery.parseXML()'返回。 ref:http://api.jquery.com/jquery.parsexml/ – dreamweiver