I have set a variable in my url wich i get in my next page, this variable is the title of an article in my xml. I have tried to get the rest of the contents in this article and misserably failed… The layout of the xml is.
<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>
When i search for 18/05/1987 i want do display nirvana and led + description, so the whole content of the corresponding node.
EDIT I have tried the code and only seem to get 1 answer… im pretty new so i don’t get why i don’t get more answers when the check is 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>")
}
}
Ty in advance
Here is a little JavaScript function I use to create an XML DOM Document I can work with…
You can then use this like so to get the title, for example…
EDIT: As you appear to want to perform a search on the XML you can do something like this…
See here for more information on XML DOM function and properties