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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:25:33+00:00 2026-06-15T01:25:33+00:00

I am having a some problems in getting a node value from a XML

  • 0

I am having a some problems in getting a node value from a XML file

My XML looks like this:

<item>
   <item1><Description>test</Description></item1>
   <item2><Description>test2</Description></item2>
   <item3><Description>test3</Description></item3>
</item>

And I am trying to get ‘test2’ from Item2 > Description.

I am able to get the xml file display in a alert messagebox but can’t seem to get the value i am looking for.

I am trying to do this in JavaScript and so far I have come up with the following:

function get_item()
{
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }


      xmlhttp.onreadystatechange=function()
       {

       if (xmlhttp.status==200)
         {
         //alert(xmlhttp.responseText);
          xmlDoc = xmlhttp.responseText;

            var item = xmlDoc.getElementsByTagName("Description")[0]; 
                item = item.childNodes.length ? item.childNodes[0].nodeValue : "" ;

             alert(item)

         } else
         {
         alert('Panel not communicating.Reason: '+xmlhttp.status);
         }
       }



    xmlhttp.open("POST","http://192.168.0.5/xml_file.xml",false);

    xmlhttp.send();
}

If I remove:

var item = xmlDoc.getElementsByTagName("Description")[0]; 
                    item = item.childNodes.length ? item.childNodes[0].nodeValue : "" ;

and change the alert to:

alert(xmlDoc)

it alerts my XML file, so i know it’s reading my xml file but can’t get the value.

Am I doing something wrong or is there a better way to get this value?

(I don’t want to use jQuery for this)

  • 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-15T01:25:34+00:00Added an answer on June 15, 2026 at 1:25 am

    Use xmlhttp.responseXML instead of xmlhttp.responseText, I think there might be some issue with older versions of IE though, in which case you can try

    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlDoc.loadXML(xmlhttp.responseText); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems getting a UIImage from a CVPixelBuffer . This is what
I'm having some problems getting the Friend List of a twitter user from R,
I am having some problems getting this animation to execute. I have a feeling
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the
I am having some problems getting this layout to work properly in IE (both
I am having some problems getting this code to work properly. I want to
I am having some problems getting this Wordpress nav bar to render correctly in
I am having some problems getting KnockoutJs beforeRemove and afterAdd handlers to fire. This
I'm having some problems getting this to look good in IE, FireFox, Opera, Chrome
Im having some problems getting the Sticky Footer to work on my site. If

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.