Jump to content

Display Xml


gongpex

Recommended Posts

Hello everyone, A few days ago I download a xml file from w3schools that namely cd_catalog.xml , I combined it with html file that I download also, for example :

<html><body><script type="text/javascript">if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.open("GET","cd_catalog.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML;document.write("<table border='1'>");var x=xmlDoc.getElementsByTagName("CD");for (i=0;i<x.length;i++)  {  document.write("<tr><td>");  document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);  document.write("</td><td>");  document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);  document.write("</td></tr>");  }document.write("</table>");</script></body></html>

after I download all of the code, I tried to test it to browser, but the results not all browser can display it ,only firefox that can display it, My question : if I want to display xml file, Am I need to upload it to server like apache? please someone help me Thank you

Link to comment
Share on other sites

Internet Explorer doesn't let you load files from the filesystem. You have to upload it to a server, even if it's just localhost. As far as I know, other browsers should work just fine.

Link to comment
Share on other sites

It doesn't necessarily need to be domain hosting. Uploading it to any server will work as long as you're accessing the file through HTTP. Apache is a server. You can install it on your computer, and if you run the script through http://localhost or http://127.0.0.1 it will work fine. A doctype declaration doesn't make any difference. What matters is the environment. Internet Explorer has a secirty feature that blocks AJAX requests on the local filesystem.

Link to comment
Share on other sites

so, if I upload xml file, instance note.xml on the apache server on htdocs, then I type on browser address like : localhost/note.xml on the IE it will shown? ------------------------------------------------------------------------------- hi Ingolme are you online now?

Link to comment
Share on other sites

so, if I upload the xml files on apche2triad that have installed PHP , the xml file cannot display ? or it must need special apache like apache tomcat that designed special for java and jsp? ___________________________________________________________________________- --sorry--whether your occupation is a moderator on this forum?

Link to comment
Share on other sites

The XML file will always display. And as long as it's on the same server, Javascript can read the XML file. I'm a university student. I just visit the forums on my spare time. This isn't a real occupation, I'm not getting paid for it.

Link to comment
Share on other sites

so, first I must create the xml file , then I create .htm that connect with the xml file like I was upload on above then I must type on browser address like : localhost/example.html? by the way, Is apache2triad can be used to display this xml files? besides apache, do you know another software that can be use as server?

Link to comment
Share on other sites

IIS for ASP right? I had tried your advice and it's work ------------------------------------------------------------ well, I very sleepy now, and tomorrow I must go to work muchas gracias happy weekend bye

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...