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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:23:21+00:00 2026-05-14T18:23:21+00:00

i am beginner with chrome extension.There is simple problem. There is the code in

  • 0

i am beginner with chrome extension.There is simple problem.
There is the code in my extension,but it do not work.I don’t know how to figure it out.
In my extension, i used a xml file to stroe some data.There is the
code in my background.html,but it do not work

    <!DOCTYPE html>
<html>
<head>
</head>

<body>
<script>
function loadXmlFile(){
   var xmlDom = null;
   var xmlhttp = new XMLHttpRequest();
       if( xmlhttp ){
               xmlhttp.onreadystatechange = function(){
                       if( xmlhttp.readyState == 4 ){
                            if( xmlhttp.status == 200 ){
                                       xmlDom = xmlhttp.responseXML;
                               }
                       }
               }
               xmlhttp.open( "GET",chrome.extension.getURL("/xml/123.xml"),true);
               xmlhttp.send( null );
       }
       return xmlDom;
}

var xmlDom = loadXmlFile();
var s = xmlDom.getElementsByTagName( "to" );
alert( s[0].nodeType );
</script>
</body>
</html>

I used developer tools to debug,but it says ” Cannot call method
‘getElementsByTagName’ of null”…
who can help me?

  • 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-14T18:23:22+00:00Added an answer on May 14, 2026 at 6:23 pm

    The return value of loadXmlFile is initialized to null and only set to something in the onreadystatechange callback, so at the time the function returns it is probably still null. Hence xmlDom is null on this line where you’re getting your error:

    var s = xmlDom.getElementsByTagName( "to" );
    

    That line and the alert should be within the innermost block of your onreadystatechange callback.

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

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you use a for loop to generate the <option>… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer To convert a numerical character ('0' – '9') to its… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer echo ${!${false}=getArray()}[0]; This is how it works, step by step… May 16, 2026 at 5:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am a beginner with chrome extension. In my content_script.js, how can a get
I'm Java beginner, but I thought that when using try-catch-finally I don't have to
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner in python, but been programming for about 5 years now. I suspect I
Beginner question: I want to debug some code that compiles. I pressed debug, it
level: beginner the following code will print 'False' def function(x): if len(x) == 5:
I'm beginner with iPhone and want to know how to add a view in
(Beginner to HTML) I have made a Photoshop mock-up of the website I want
Beginner Git question: In the Mercurial world, hg tags gives me a list of
Beginner question. How do I substitute: $_SESSION['personID'] for {personID} in the following: public static

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.