我已经在我的网址中设置了一个变量,我在我的下一页,这个变量是我的XML文章的标题。我试图得到这篇文章中剩下的内容,错过了失败... xml的布局是。如何使用javascript获取某个标题的内容?
<title>
<artist>
Nirvana
</artist>
<description>
Nirvana in concert
</description>
<date>
18/05/1987
</date>
</title>
<title>
<artist>
led zeppelin
</artist>
<description>
led in concert
</description>
<date>
18/05/1987
</date>
</title>
当我搜索18/05/1987我想要做的显示必杀技,并导致+的描述,所以相应的节点的全部内容。
编辑我已经尝试了代码,并似乎只拿到1个回答...即时通讯相当新的,所以我不知道为什么我在支票itterated没有得到更多的答案
xmlDoc=loadXMLDoc("data.xml");
var hash = getUrlVars();
var date = hash['date'];
var nodeList = xmlDoc.getElementsByTagName("article");
for (var i = 0; i < nodeList.length; i++) {
var titleNode = nodeList[i];
if(titleNode.getElementsByTagName("urltext")[i].nodeValue = date){
document.write("<div style='width:450px;'>")
document.write("<p>"+titleNode.getElementsByTagName("title")[i].childNodes[0].nodeValue+"</p>");
document.write("<p>"+titleNode.getElementsByTagName("description")[i].childNodes[0].nodeValue+"</p>");
document.write("<p>"+titleNode.getElementsByTagName("urltext")[i].childNodes[0].nodeValue+"</p>");
document.write("</div>")
}
}
泰提前
看到此链接http://stackoverflow.com/questions/9065197/jquery-validation-plugin-using-custom-error-messages-from-xml-file/9065309 – mgraph 2012-02-07 10:55:59