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've tried to implement an easy Node Class but when i try to access
How can I control a flash movie in a window from a child (pop-up)
I open a window/tab in Chrome: childWin = window.open('child.html'); Then I try to call
I have some code that works in IE7 and 8 but not in 9
I have a documentFragment with several child nodes containing some .data() added like so:
I've got some simple XML-handling code that's supposed to locate a child node of
I can't figure out how to access the data between the inner nested tags.
I got a couple different formats that come in but I can't figure out
I'm trying to access protected variables in a second-child class extended from its parent,
I have appended new elements in an empty ul but when I try to

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.