List Info

Thread: RE: GSXPathContext examples ?




RE: GSXPathContext examples ?
country flaguser name
United States
2008-01-05 07:56:15
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>

You can find lot more examples on the web.  It's a very nice
tool to quickly extract
a piece of information from an XML file. 

Thanks


-----Original Message-----
From: Philippe Roussel <p.o.rousselfree.fr>
Sent: Thursday, January 3, 2008 3:37pm
To: discuss-gnustepgnu.org
Subject: GSXPathContext examples ?

Hi all,

I know that GSXPathContext's documentation says I just have
to learn
xpath syntax but I would like to know if someone uses
GSXPathContext
and its friends successfully.

Any example (xml file and xpath query) verified to work with
GNUstep
would be great.

Thanks,
Philippe
-- 
Il est temps pour la race humaine d'entrer dans le système
solaire. Dan Quayle



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep




_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Re: GSXPathContext examples ?
country flaguser name
France
2008-01-05 11:34:43
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
AV:"> 
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



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustepgnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )