Thanks to everyone who has replied. I worked with the SimpleXPathAPI example and determined that my fudamental problem was not wrapping my input with single quotes. Once I did that, the sample started doing what I expected. Now here is what I would really like to do: My XML file has many more entries in each section and some entries could be several (4+) levels deep. Once I parse the document, I want to be able to do things like get all the player nodes that have swords with an active value of '1'. Or, I may simply want to get the name of a player with a given ID. I am using code from 'C++ Cookbook' as my starting point. See Attached. The main difference I see is that I am creating my document using the XercesDOMParser. If I need to rethink my approach, please let me know.
Regards, Jonathan -----Original Message----- From: David Bertoni [mailto:[EMAIL PROTECTED] Sent: Thursday, March 01, 2007 12:48 PM To: xalan-c-users@xml.apache.org Subject: Re: Xalan C / XPath question Coker, Jonathan M wrote: > Hello, > I am pretty new to this so I hope someone can help me. I am trying > to access data using XPath and I am getting some confusing results. > The XML looks like this: > > <?xml version="1.0" encoding="UTF-8"?> <Game Name="Game1"> > <Player> > <Name ID="1">Jonathan</Name> > <Weapon Active="0">Gun</Weapon> > </Player> > <Player> > <Name ID="2">Sam</Name> > <Weapon Active="1">Sword</Weapon> > </Player> > </Game> > > Before I start posting code I will start simple. If I put in an XPath > expression like /Game/Player/Name/text() I get back a nodeset with > 'Jonathan' and 'Sam'. If I put in /Game/Player/[EMAIL PROTECTED]/text() I > was expecting to get just 'Jonathan'. However, I get a zero length > nodeset. Am I forming the XPath expression correctly (XMLSpy says > parses it OK)? Thank you for any help. I cannot reproduce your problem. When I use the SimpleXPathAPI sample application and use your source file, I get the expected result. What version of Xalan-C are you using? Dave
4-23.cpp
Description: 4-23.cpp