Logicaly selecting a section of XML
-
Ok so I made an XML data sheet that works fine, but i know i will need the data. So i need to be able to make the XML display the correct info according to the id="" How do I do this? script.js: //parser start var xmlDoc; function loadXML(){ //load xml file // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("product_info.xml"); getmessage(); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.load("product_info.xml"); xmlDoc.onload=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; } //parser end function dio(){ window.open("dio.html") } dio.html: Product Info
Product Information
File Name:
File Size:
File Summary:
File Version:product_info.xml: Bustin' Blox 2 Mb Our version of Brick. Only One Level (Kinda Sucks) 1.0.0
-
Ok so I made an XML data sheet that works fine, but i know i will need the data. So i need to be able to make the XML display the correct info according to the id="" How do I do this? script.js: //parser start var xmlDoc; function loadXML(){ //load xml file // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("product_info.xml"); getmessage(); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.load("product_info.xml"); xmlDoc.onload=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; } //parser end function dio(){ window.open("dio.html") } dio.html: Product Info
Product Information
File Name:
File Size:
File Summary:
File Version:product_info.xml: Bustin' Blox 2 Mb Our version of Brick. Only One Level (Kinda Sucks) 1.0.0
hallo? Any one there?