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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:32:33+00:00 2026-06-12T10:32:33+00:00

To better understand the difference between textConent and nodeValue I’d like to find out

  • 0

To better understand the difference between textConent and nodeValue I’d like to find out why using nodeValue in my code is not working. I have the following XML string which gets loaded through AJAX via a jQuery callback. If you look at the center of the loop, that section will produce a null value if I use nodeValue in place of textContent.

XML

<?xml version="1.0" encoding="UTF-8"?>
    <Sensors>
        <Sensor>
            <id>56</id>
            <state>false</state>
        </Sensor>
    </Sensors>

I use this function below to parse the XML.

JavaScript

  function parseSensors(data,status,xhr) {
         var xml = xhr.responseXML;
         var sensors = xml.documentElement.childNodes;

         var list="<ul>";             
         for(var i=0; i < sensors.length; i++) {
             list= list +"<li>"+sensors[i].childNodes[0].textContent+"</li>";                 
         }
         list=list+"</u>";
         document.getElementById("real-time_active_sensors").innerHTML=list;            
     }
  • 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-12T10:32:34+00:00Added an answer on June 12, 2026 at 10:32 am

    The text portion of a node is actually a child of the node itself. If a node has no data in it, such as then a call to childNodes[0].nodeValue will fail. You need to check for how many childNodes are actually present before you attempt to access them. Otherwise you’ll need to enforce a protocol that demands that when XML data is created it cannot contain empty tags.

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

Sidebar

Related Questions

I want to understand better the difference between using 'new' to allocate memory for
Help me please to find out what's the difference between these two code snippets:
I'm trying to understand the difference between working with just long, long2, long3, long4,
So I've been trying to better understand the difference between these two but all
I have been trying to understand the difference between different references but the theory
I'd like to better understand the creation, allocation, and binding of OpenGL ES framebuffers,
I would like to better understand my application and specifically its memory footprint. I
I'm trying to better understand the concept of 'autocommit' when working with a Postgres
I am trying to better understand when I should and should not use Iterators.
I would like to better understand the basic steps needed to a take an

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.