Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6672961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:34:13+00:00 2026-05-26T03:34:13+00:00

I am trying to run the sample code on W3School http://www.w3schools.com/xml/xml_to_html.asp I copied the

  • 0

I am trying to run the sample code on W3School
http://www.w3schools.com/xml/xml_to_html.asp

I copied the html+js codes and saved into a html file.
I also downloaded their cd_catalog.xml and put it right beside the html file.

But when I run the html on Chrome, it shows nothing. It is also not working on IE.

Seems the problem is on the line “xmlhttp.send()”, because I tried to put an alert right before it, the alert showed, but if I put the alert after that line, then it won’t show up.

Anyone can help please?

<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.xml",false);
alert("before");
xmlhttp.send();
alert("after");
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>

the xml file is on http://www.w3schools.com/xml/cd_catalog.xml

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:34:14+00:00Added an answer on May 26, 2026 at 3:34 am

    This will not work if you are running the page as a local file. You need to run it through a webserver (like Apache) in order for the http client/server conversation to work. Can you verify that you are running it through a web server?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to run the sample code here: http://www.nikhilk.net/Live-Search-REST-API.aspx I get: Error 52 The
I am trying to run the sample code for tftp server. I get no
I am newbie with JPA. I'm trying to run some sample code using JPA
I have downloaded TableView sample code '4_TableViewCellSubviews' from internet. I am trying to run
I'm trying to run an ASP.NET 2.0 application on an XP machine. As far
I'm trying to run sample Perl script on Windows 7 and I configured IIS
I'm trying to run a c++ 2d array (pretty simple file) and it works
I am trying to run the VS 2008 SP1 installer , but it says
I'm trying to run a batch file, as another user, from my web app.
I'm trying to run some queries to get rid of XSS in our database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.