Hello, this might be the most stupid thing a man can ask here, but i haven't used javascript and xml for couple of years and i have forgotten everything.
for example, Lets say i have a XML document called "phones.xml"
in this document, i have this information:
<phones> <galaxy_s4> <galaxy_s4_price>300 Eur</galaxy_s4_price> <galaxy_s4_price_per_month>12 Eur</galaxy_s4_price_per_month> </galaxy_s4> <lg_g2> <lg_g2_price>300 Eur</lg_g2_price> <lg_g2_price_per_month>12 Eur</lg_g2_price_per_month> </lg_g2> <htc_one> <htc_one_price>300 Eur</htc_one_price> <htc_one_price_per_month>12 Eur</htc_one_price_per_month> </htc_one> <meizu_mx4> <meizu_mx4_price>300 Eur</meizu_mx4_price> <meizu_mx4_price_per_month>12 Eur</meizu_mx4_price_per_month> </meizu_mx4></phones>
now, i want to display the price and price_per_month in my text just for the galaxy s4, but i don't want to put this information as a table, that shows all prices. i want just to print out for galaxy s4. I want to use this information in my text.
now, i tried to make an HTML document, that would show the XML information, but it doesnt work.
<head></head><body><script>if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); }else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.open("GET","phones.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML;var galaxy_s4 = xmlDoc.getElementsByTagName("galaxy_s4");var galaxy_s4_price = xmlDoc.getElementsByTagName("galaxy_s4_price")[0];var galaxy_s4_ppm = xmlDoc.getElementsByTagName("galaxy_s4_price_per_month")[0];document.write('for our latest, offer, the galaxy s4 costs only ');document.write(galaxy_s4_price);document.write(' and the price per month is ');document.write(galaxy_s4_ppm);</script></body>
when i try to run this code, instead of showing the price, it just prints out "undefined". how can i make the code to run and show my my information?