尝试使用下面显示的javascript代码获取以下XML的属性失败,但不确定它是否会起作用,有什么帮助?:
<!doctype html>
<head></head>
<body>
<!- some fancy stuff here
-->
<?xml version="1.0"?>
<details ><detail id="101" name="Vincent" address="KilWith"
busname="vintechsurveys" lat="-1.28" lng="36.79" distance="3.796344552327"/>
<detail id="102" name="Dan" address="Derman"
busname="fancyname" lat="-1.29" lng="39.79" distance="11.796344552327"/>
</details>
<script>
var detailNodes = document.getElementsByTagName("detail");
for (var i = 0; i < detailNodes.length; i++)
{
var id = detailNodes[i].getAttribute("id");
var name = detailNodes[i].getAttribute("name");
.....
}
</script>
</body>
PS,请注意XML不在另一个文件中