Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional Ajax ISBN: 978-0-471-77778-6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 15th, 2007, 09:37 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error with oNodes zXPath in chapter 4

Hi:

I like this book so far but hit a problem in chapter 4, "Cross-Browser XPath", p108.

In file "NameSpaceBooks.htm":

var oRoot = oXmlDom.documentElement;
var sXPath = "na:book/pub:name";
var oNodes = zXPath.selectNodes(oRoot, sXPath, sNameSpace);
if (oNodes.length > 0) {
alert(oNodes.length + " nodes selected with '" + sXPath + "'");
}

oNodes.length returns 0 for me.
The file NameSpaceBooks.htm shows as a blank page in both FF and IE.
NameSpaceBooks.xml is fine as far as I can tell.

I am using * JavaScript zXml Library * Version 1.0.2

Any advice appreciated.

Chung Wang

Reply With Quote
  #2 (permalink)  
Old January 15th, 2007, 10:33 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

There is a slight error in the book regarding how to set namespace mappings for zXml which should be fixed for the next print run.
You need something like:
Code:
var namespace1 = "<namespace URI for na here>";
var namespace2 = "<namespace URI for pub here>";
var oNamespaceMapper = {na: namespace1, pub: namespace2};
var oRoot = oXmlDom.documentElement;
var sXPath = "na:book/pub:name";
var oNodes = zXPath.selectNodes(oRoot, sXPath, oNamespaceMapper);
if (oNodes.length > 0)
{
  alert(oNodes.length + " nodes selected with '" + sXPath + "'");
}
You will need to replace the namespace declarations with the real ones.

--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error with chapter 7 jdz66 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 August 21st, 2006 05:19 PM
Parse error in error handler (Chapter 8) Funky Monk BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 August 6th, 2004 08:59 AM



All times are GMT -4. The time now is 05:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.