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

  • Home
  • SEARCH
  • 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 3453184
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:20:42+00:00 2026-05-18T09:20:42+00:00

My script is loading some data from an XML file and printing a table

  • 0

My script is loading some data from an XML file and printing a table with it.

    function draw_schedule() {
    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","schedule.xml",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;

    document.write("<table width='100%' border='1'>");
    var x=xmlDoc.getElementsByTagName("day");
    for (i=0;i<x.length;i++) {// number of days
      document.write("<tr><th colspan='2'>");
      document.write(x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue);// the date for each day
      document.write("</th></tr>");
      var y=x[i].getElementsByTagName("session");// daily sessions
      for (j=0;j<y.length;j++) {
            document.write("<tr><td>");
            document.write(x[i].getElementsByTagName("title")[j].childNodes[0].nodeValue);
            document.write("</td><td>");
            document.write(x[i].getElementsByTagName("time")[j].childNodes[0].nodeValue);
            document.write("</td></tr>");
    }
  }
    document.write("</table>");
}

If I call the function (separate file) from the HTML file, it prints the table and afterward prints ‘undefined’. If I alternatively embed the script in the HTML, it prints the table without printing ‘undefined’. I can’t figure-out why having the script in a separate file would change its behaviour. I would love for someone with more wisdom than I to explain. Thanks!

  • 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-18T09:20:43+00:00Added an answer on May 18, 2026 at 9:20 am

    draw_schedule() returns no value (undefined). You’re possibly calling the function with document.write:

    document.write(draw_schedule());
    

    draw_schedule() returns undefined in this case, and the result would look like this:

    document.write(undefined);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have write a code for loading html dynamically through jQuery $(table).eq(5).html('<table><tr><td>some data</td></tr></table><script language=JavaScript>function
I have a php script that loads data from a database. The table I
I'm loading some HTML from a file via AJAX, trying extra a block from
I'm using this script below for loading a hidden div, inside another: $(document).ready(function(){ $(function()
After loading a PHP template (using jQuery's load function), this simple script won't make
$('a').click(function(event){ $('body').html('loading...'); $.post('www.sitename.com/hello',{site:http//:www.google.com},function(data) { alert(data); }); event.preventDefault(); }); I am using the above script
I'm trying to download some data using pure javascript/html from cross-domain, dropbox to be
I'm loading from DB some html (using ajax post request), it looks like: <div
I'm trying this source where jqGrid gets some json data from django: link Unfortunately
I have been working on code that parses external XML-files. Some of these files

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.