gongpex Posted November 25, 2011 Share Posted November 25, 2011 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 More sharing options...
Ingolme Posted November 25, 2011 Share Posted November 25, 2011 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 More sharing options...
gongpex Posted November 26, 2011 Author Share Posted November 26, 2011 So, I must upload it to domain hosting? and whether apache is not a server? If I used DTD like <!DOCTYPE> it can take effect? please answer me thanks. . . . . . Link to comment Share on other sites More sharing options...
Ingolme Posted November 26, 2011 Share Posted November 26, 2011 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 More sharing options...
gongpex Posted November 27, 2011 Author Share Posted November 27, 2011 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 More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 Yes, it should. Link to comment Share on other sites More sharing options...
gongpex Posted November 27, 2011 Author Share Posted November 27, 2011 so, it same when I using PHP? ----------------------------------------------------------- how often you online a week? Link to comment Share on other sites More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 PHP files should run on localhost if your server software has PHP installed. I'm online basically every day at random intervals. Link to comment Share on other sites More sharing options...
gongpex Posted November 27, 2011 Author Share Posted November 27, 2011 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 More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 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 More sharing options...
gongpex Posted November 27, 2011 Author Share Posted November 27, 2011 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 More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 The server software doesn't matter. Any server can send XML data. As for other software, there's IIS, for Windows, but it's not free. Link to comment Share on other sites More sharing options...
gongpex Posted November 27, 2011 Author Share Posted November 27, 2011 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 More sharing options...
Ingolme Posted November 27, 2011 Share Posted November 27, 2011 IIS works best with ASP and ASP.NET but it's possible to get it to run PHP. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.