~Ok so this may seem like deja vu to some, but i need to find a way to use XPath to do an XML Look up. My server can only do Javascritp (duh) or PHP.
~I want to be able to click on a link in an HTML or PHP page and get two dialogues: 1. the Download window 2. the Information Window
~The Information window is my problem. I need to have just one HTML (or PHP0 page for the window and just one XML page. This XML page would have all the information on the products.
~The Information window needs to access the XML page, get the correct entry, load it and display it.
~Does anyone have any idea how to do this, or where I could learn how to do this?
It doesn't matter what language you use on the server-side as long as it can spit out XML. I'm using jQuery for doing something very similar on the client-side.
Basically, I have the following jQuery code:
The prog.xml file contains XML similar as the following one:
You can see that jQuery lets you specify an XPath expression (prog/entry) for selecting DOM nodes in the XML retrieved from the server. From there, everything else is basic stuff.
All the parts of the code the poster thing wont allow is seperated by a space
Script.js var xmlDoc; products.function(id, name, file_size, summary) { this.id=id; this.name=name; this.file_size=file_size; this.summary=summary; } function loadXML(){ //load xml file // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("product_info.xml"); var id=attrs.getNamedItem("id").value; var name=attrs.getNamedItem("name").value; var version=parseFloat(attrs.getNamedItem("file_size").value) var file_size=attrs.getNamedItem("summary").value; getmessage(); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.load("product_info.xml"); var id=attrs.getNamedItem("id").value; var name=attrs.getNamedItem("name").value; var version=parseFloat(attrs.getNamedItem("file_size").value) var file_size=attrs.getNamedItem("summary").value; xmlDoc.o nload=getmessage; } else { alert('Your browser cannot handle this script'); } } // Actual message maker function getmessage() { document.getElementById("name").innerHTML=xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue; document.getElementById("file_size").innerHTML=xmlDoc.getElementsByTagName("file_size")[0].childNodes[0].nodeValue; document.getElementById("summary").innerHTML=xmlDoc.getElementsByTagName("summary")[0].childNodes[0].nodeValue; document.getElementById("version").innerHTML=xmlDoc.getElementsByTagName("version")[0].childNodes[0].nodeValue; }