[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

text() & childNodes[0] of xPath

Subject: text() & childNodes[0] of xPath
From: Sanjaya Liyanage <sanjayacl@xxxxxxxxx>
Date: Wed, 10 Mar 2010 12:02:38 +0530
 text() & childNodes[0] of xPath
Hi,
  While I am going through the examples of Xpath @ w3schools site
(http://www.w3schools.com/xpath/xpath_examples.asp ) I came across
this doubt.
  <?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

<book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

</bookstore>

The above xml file is the resource.

1)path=/bookstore/book/price/text()

and the part of the script is given below.

var nodes=xml.selectNodes(path);

for (i=0;i<nodes.length;i++)
  {
  document.write(nodes[i].nodeValue);
  document.write("<br />");
  }

2)path=/bookstore/book/price

and the part of the script is given below.

var nodes=xml.selectNodes(path);

for (i=0;i<nodes.length;i++)
  {
  document.write(nodes[i].childNodes[0].nodeValue);
  document.write("<br />");
  }
}

In both the above cases the output is same.So I want to know whether
the above two methods are same in functionality wise or are there any
significant different between these two methods?

Thanks
Sanjaya.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.