discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GSXPathContext examples ?


From: Philippe Roussel
Subject: Re: GSXPathContext examples ?
Date: Sat, 5 Jan 2008 18:34:43 +0100
User-agent: Mutt/1.5.11

On Sat, Jan 05, 2008 at 02:56:15PM +0100, Nicola Pero wrote:
> Yes, GSXPathContext has been/is being used succesfully in production systems. 
> :-)
> 
> Here is a trivial example which I just made up:
> 
> <test>
>   <item>
>     <description>This is an item</description>
>     <number>1</number>
>   </item>
>   <item>
>     <description>This is another item</description>
>     <number>2</number>
>   </item>
> </test>
> 
> Here are a few demo XPath queries (tested with gnustep-base 1.14.0 + libxml 
> 2.6.16):
> 
> 'string(/test/item[1]/description/text())' returns the GSXPathString 'This is 
> an item'
> 
> 'string(/test/item[2]/description/text())' returns the GSXPathString 'This is 
> another item'
> 
> '//number' returns a GSXPathNodeSet containing two XML_ELEMENT_NODEs, for the 
> two
> tags <number>

Thanks Nicola, now I figured out that my code doesn't work because of
namespaces. My data starts with 
<D:multistatus xmlns:ap="http://apache.org/dav/props/"; xmlns:D="DAV:"> 
and if I remove all 'D:' and 'ap:' from it my queries work
beautifully. I tried using namespaces in the query (as in "//D:href")
but I can't make it work. Would you have any pointer on how to deal
with namespaces with GNUstep XPath tools ?

Philippe
-- 
Debugging is twice as hard as writing the code in the first place. Therefore, 
if you write the code as cleverly as possible, you are, by definition, not 
smart enough to debug it. BrKernighan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]