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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:42:02+00:00 2026-06-14T10:42:02+00:00

when i try to access child nodes i can , but i can’t access

  • 0

when i try to access child nodes i can , but i can’t access their value it says null

     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","obj.xml",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;
    x=xmlDoc.getElementsByTagName("Objnode")[0].childNodes; 
    y=xmlDoc.getElementsByTagName("Objnode")[0].firstChild;    
    for (i=0;i<x.length;i++)
    {
    if (y.nodeType==1)
      {//Process only element nodes (type 1)
      document.write(y.nodeName + "<br>"); change it to y.nodeValue it says null!
      }
    y=y.nextSibling;
    }

my xml is like

    <Objnode>
            <Object1>something</Object1>
            <Object2>something</Object2>
    </Objnode>

above code works but the line

document.write(y.nodeName + "<br>"); 

when changed it to y.nodeValue it says null!

  • 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-06-14T10:42:04+00:00Added an answer on June 14, 2026 at 10:42 am

    Actually nodeType 1 is an HTML element, i.e. div, span etc and an element doesn’t has any nodeValue instead it could contain child nodes and remember that any text inside an element is also a node (text node). Look at this example

    HTML

    <div id="d">First Text Node <br /> Another Text Node</div>​
    

    JS

    var n=document.getElementById('d');
    alert(n.firstChild.nodeValue);​ // First Text Node
    alert(n.childNodes[2].nodeValue); // Another Text Node
    

    So, in your example y.nodeValue is null.

    DEMO.

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

Sidebar

Related Questions

I try to access the MainContentBlock control from the aspx, but unable to do
I try to use Python envoy for better access to Shell programs. But i
How can I control a flash movie in a window from a child (pop-up)
I try to access session variables stored on a different page. When I have
When try to access site i created after 3 login attempts it gives unauthorised
When I try to access my site, then check my Heroku logs, I see
Every time I try to access my localhost/phpmyadmin it gives me this error --->
When you try to access a key which isn't in a Dictionary (for example),
When I try to access info that is not presented in xml like so:
We know that if we try to access a nonexistent key of std::map with

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.