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 6072335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:08:56+00:00 2026-05-23T10:08:56+00:00

I am trying to load an XML file and get its DOM object. I

  • 0

I am trying to load an XML file and get its DOM object. I think the error is with this code:

// Takes an XML document and loads it and returns a DOM of the document
function loadXMLDoc(filepath)
{
    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", filepath, false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    return xmlDoc;
}

The code stops executing at xmlhttp.send(). I get the following error message:

XMLHttpRequest cannot load file://localhost/Users/Dylan/programming/projects/personalpage/resources/cool-data.xml. Cross origin requests are only supported for HTTP.
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101

This highlights the xmlhttp.send() line. I had this working before and I don’t think I made any changes to the file. The only difference I know is that I am now executing this on my local machine. Before I was using an IDE hosted online (cloud9) so the files were all remote on a web server. Also, it worked on Windows and I’m now on a Mac.

Edit: I called the function with the argument: "../resources/items-data.xml"
and all of my work is on my local machine. Equal level directories are js, html, css, and resources.

  • 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-23T10:08:56+00:00Added an answer on May 23, 2026 at 10:08 am

    You could use XHR locally (in file: origin), but there is a catch: Google Chrome and Firefox (I believe) will prevent you from accessing files other than the files in the same directory with the html file. That is

    file://localhost/Users/Dylan/programming/projects/personalpage/index.htm

    can access

    file://localhost/Users/Dylan/programming/projects/personalpage/abc.xml, or
    file://localhost/Users/Dylan/programming/projects/personalpage/abc.json.js

    but not

    file://localhost/Users/Dylan/programming/projects/personalpage/resources/cool-data.xml, or
    file://localhost/etc/passwd

    This restriction has only be added to recent version. I guess that’s the reason you didn’t find out in the first place.

    P.S. Next time, do everybody a favor by using jQuery or other Javascript library rather than reinventing the wheel.

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

Sidebar

Related Questions

I'm trying to get a webstageview to load a local html file....this code works
I'm trying to use the following code # LOAD XML FILE $XML = new
I am trying to load a xml document I created using PHP and DOM
I am trying to load a very basic XML document but everytime I get
I'm trying to parse an XML file using PHP, but I get an error
I am trying to load an XML file that asks for a username and
I'm trying to load an XML file with a list of books, I looked
I'm trying to load a simple Xml file (encoded in UTF-8): <?xml version=1.0 encoding=UTF-8?>
I'm trying to load country names and their cities from an XML file in
I'm trying to load Gravatars into Flash. Luckily, they provided a crossdomain.xml file at

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.