我正在尝试从网络上以下xml文件-http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml获取html表的货币汇率,但失败了。我的代码如下:有人可以帮忙吗?
<!DOCTYPE html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
</head>
<body>
<div id="x-rates">
</div>
<script>
$.ajax({
type: "GET",
url: "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",
dataType: "xml",
success: function (xml) {
var xmlDoc = $.parseXML(xml),
$xml = $(xmlDoc);
$xml.find("Cube").each(function () {
$("#x-rates").append($(this).text() + "<br />");
});
}
});
</script>
</body>
</html>