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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:24:25+00:00 2026-05-27T02:24:25+00:00

I’m having an issue reading the below XML document in Chrome – nothing seems

  • 0

I’m having an issue reading the below XML document in Chrome – nothing seems to turn up but it works perfectly fine in Firefox. Is it a browser compatibility issue?

  <html>
  <head>
    <title>XML</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
    <script type='text/javascript'>

    function XMLload(){
        jQuery.post(url,function(data){getxml(data);},'xml');
    }

    function dataFromTag(node,t){
        var d=node.getElementsByTagName(t);
        if(d.length==0)
            return('');
        return(d[0].firstChild.nodeValue);
    }

    jQuery(document).ready(function(){XMLload();});

    // all the code above this line can be re-used without change
    // all the code below will need altering for a different document and different structure

    var url='cohort.xml';
    var xmlcohort;

    function getxml(xmldoc){
        xmlcohort = xmldoc.getElementsByTagName('student');

        var hstr = '<html><head><title></title></head><body>';
        hstr += '<p>Cohort:</p><form>';
        hstr += '<select size="' + xmlcohort.length + '" onclick="parent.student_info(this.selectedIndex);">';

        for( var i = 0; i < xmlcohort.length; i++ ) {
            hstr += '<option>' + dataFromTag(xmlcohort[i], 'name') + '</option>';
        }
        hstr += '</select></form></body></html>';

        with( document.getElementById('cohort').contentDocument ) {
            open();
            write(hstr);
            close();
        }
    }

    function student_info(idx) {
        var hstr = '<html><head><title></title></head><body><dl>';
        hstr += '<dt>Name</dt><dd>' + dataFromTag(xmlcohort[idx], 'name') + '</dd>';
        hstr += '<dt>Module</dt><dd>' + dataFromTag(xmlcohort[idx], 'module') + '</dd>';
        hstr += '<dt>Mark</dt><dd>' + dataFromTag(xmlcohort[idx], 'mark') + '</dd>';
        hstr += '</dl></body></html>';

        with( document.getElementById('student').contentDocument ) {
            open();
            write(hstr);
            close();
        }
    }

    </script>
  </head>
  <body>
    <iframe id='cohort' height='300' width='200'></iframe>
    <iframe id='student' height='300' width='200'></iframe>
    <p>Here is the <a href="cohort.xml">xml data</a></p>
  </body>
</html>

Here are the contents of cohort.xml:

<cohort>
<student>
<name>Bob</name>
<module>COA122</module>
<mark>72</mark>
</student>
<student>
<name>Alice</name>
<module>COB250</module>
<mark>84</mark>
</student>
<student>
<name>Kate</name>
<module>COP180</module>
<mark>99</mark>
</student>
</cohort>

I get this error when I run it from my hard drive. The entire page doesn’t load – it only works when I put it on a web server:

XMLHttpRequest cannot load file:///C:/Users/methuselah/Desktop/cohort/cohort.xml. Origin null is not allowed by Access-Control-Allow-Origin.
  • 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-27T02:24:26+00:00Added an answer on May 27, 2026 at 2:24 am

    This is a known issue in Chrome: http://code.google.com/p/chromium/issues/detail?id=40787

    If this is just for testing and development, there is a Chrome command line flag you can use to work around this: --allow-file-access-from-files. I just tested it and it makes your pages work locally in Chrome for me.

    Windows: chrome.exe --allow-file-access-from-files

    Mac: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files

    Linux: Linux users don’t need instructions for how to get things working from the command-line! 😉

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

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.