Reading a specific product from an xml file of products

rechtbak

New Member
I have an XML file:\[code\] <?xml version="1.0" encoding="UTF-8"?><products> <product> <id>246</id> <code>Ash07-001</code> <image>C:\BowlPhotos\Thumbs\Ash07-001tmb.jpg</image> </product> <product> <id>247</id> <code>Ash07-004</code> <image>C:\BowlPhotos\Thumbs\NoBowltmb.jpg</image> </product> <product> <id>248</id> <code>Ash07-005</code> <image>C:\BowlPhotos\Thumbs\Ash07-005tmb.jpg</image> </product></products>\[/code\]And read it with this code:\[code\] document.write("<table border='1'>");var x=xmlDoc.getElementsByTagName("product");for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x.getElementsByTagName("id")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x.getElementsByTagName("code")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x.getElementsByTagName("image")[0].childNodes[0].nodeValue); document.write("</td></tr>"); }document.write("</table>");\[/code\]And that works to get all of the file.What if I only want the product with the id of 247? How do I pull that entire product out and print just that one?
 
Back
Top