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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:34:24+00:00 2026-05-15T12:34:24+00:00

Javascript: var req=xmlDoc.responseXML.selectSingleNode(//title); alert(req.text); as expected, returns the text of the first title node.

  • 0

Javascript:

var req=xmlDoc.responseXML.selectSingleNode("//title");
alert(req.text);

as expected, returns the text of the first “title” node.

but this

var req=xmlDoc.responseXML.selectNodes("//title");
alert(req.text);

returns “undefined.” The following:

var req=xmlDoc.responseXML.selectNodes("//title").length;
alert(req);

returns “2.” I don’t get it. Maybe when I selectNodes it isn’t getting the text node inside the title. That’s my guess for now…here is the xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog SYSTEM "catalog.dtd">
<catalog>
<decal>
<company>Victor</company>
<title>Wood Horn Blue Background</title>
<image>
<url>victor01.jpg</url>
<width>60</width>
<height>60</height>
<name>Wood Horn Blue Background</name>
<link></link>
</image>
<price>$15.00</price>
<instock>In Stock</instock>
<notes>no extra info</notes>
</decal>
<decal>
<company>Victor</company>
<title>Wood Horn without Black Ring</title>
<image>
<url>victor02.jpg</url>
<width>60</width>
<height>60</height>
<name>Wood Horn Without Black Ring</name>
<link></link>
</image>
<price>$15.00</price>
<instock>In Stock</instock>
<notes>no extra info</notes>
</decal>
</catalog>

thanks

  • 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-15T12:34:25+00:00Added an answer on May 15, 2026 at 12:34 pm

    selectNodes returns an array rather than a single node (hence the plural naming of the method).

    You can use an indexer to get the individual nodes:

    var req=xmlDoc.responseXML.selectNodes("//title");
    for (var i=0;i<req.length;i++) {
       alert(req[i].text);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript: function createRequestObject(){ var req; if(window.XMLHttpRequest){ //For Firefox, Safari, Opera req
I have this JavaScript: var Type = function(name) { this.name = name; }; var
I have two dates in javascript: var first = '2012-11-21'; var second = '2012-11-03';
I have this in my JavaScript var identifier = event.target.id; it works on Chrome
You can backreference like this in JavaScript: var str = 123 $test 123; str
I have this piece of code in javascript: var catId = $.getURLParam(category); In my
I have a JavaScript function as follows: function popup(username) { var req = createAjaxObject();
let's say I have this code in javascript: function doAnAjaxCall () { var xhr1
<html> <head> <script type=application/javascript;version=1.7> var req = new XMLHttpRequest(); req.open(GET,file:///Users/me/folder/items.xml, false); req.send(null); var dom
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} AFAIK, there

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.