【发布时间】:2013-12-24 15:50:41
【问题描述】:
我开始使用 XML 和 XMLHTTP-Request,但我不明白如何通过 ID 获取项目。例如:
在我的 XML 文档中,我得到了:
<note id="501">
<to>Exemplo 2</to>
</note>
<note id="502">
<to>Exemplo 2</to>
</note>
在我的 HTML 中,我得到了:
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
使用该代码,我只得到第一个 (501),但是如何通过 ID 定义并获取第二个 (502)?
PS.:我从这里得到了例子:http://www.w3schools.com/xml/xml_attributes.asp
【问题讨论】:
标签: javascript xml xmlhttprequest