Hi,
I'm trying to build an easy search engine that makes a search on a XML file.

The result of the search provides the name of images listed in the XML and I want to link it at the corrispondent image

Ex. <a href="image/product1.jpg">product</a>

This is the xml file

Code:
<?xml version="1.0" encoding="utf-8"?>
<searchable_index>
	<item>301_Beauty_naturale.jpg</item>
	<item>304M_Lotus_retro.jpg</item>
	<item>315E_Tea_ciliegio.jpg</item>
	</searchable_index>
and this is the js file
Code:
function showResults(results, searchterm) {

	if (results.length > 0) {
// if there are any results, put them in a list inside the "resultshere" div
		var resultshere = document.getElementById("resultshere");
		var header = document.createElement("h5");
		var list = document.createElement("ul");
		var searchedfor = document.createTextNode("Search results for "+searchterm);
		resultshere.appendChild(header);
		header.appendChild(searchedfor);
		resultshere.appendChild(list);
		
		for (var i=0;i<results.length;i++) {
var linkUrl=document.createTextNode(results[i].lastChild.nodeValue);
var filename = document.getElementById(results[i].lastChild.nodeValue);			
var newLink=document.createElement('a');		
newLink.setAttribute("href","images/" +filename);
			
  			// - use 'className' to create the equivalent of class="contrast"
  			
			newLink.className='contrast';
 var linkText=document.createTextNode(results[i].lastChild.nodeValue);
  			newLink.appendChild(linkText);
			
  			document.getElementById('resultshere').appendChild(newLink);
			
			
		}
the problem is that var filename can't be included in newLink.setAttribute("href","images/" +filename);
The actual file gives me the path images/null

Thanks for the help