Re: [xml] new tree.c function



Dan,

I guess the reason I was reinventing the XPath wheel was because of the following.

When I create a context like xmlXPathContextPtr pctx=xmlXPathNewContext(doc);.  When the doc is an xmlDocPtr xmlParseFile() xpath works on it.  However, the situation I'm in the doc is an xmlDocPtr created with xmlNewDoc() and xpath doesn't seem to work the same.  Below is from the debugger and shows that even though nodesetval is not NULL it's contents are.

(gdb) p *pobj
$25 = {type = XPATH_NODESET, nodesetval = 0x9cbb00, boolval = 0, floatval = 0,
  stringval = 0x0, user = 0x0, index = 0, user2 = 0x0, index2 = 0}
(gdb) p *pobj->nodesetval
$26 = {nodeNr = 0, nodeMax = 0, nodeTab = 0x0}

Dave
----- Original Message -----
From: Daniel Veillard
Date: Thursday, May 22, 2008 10:52 am
Subject: Re: new tree.c function
To: dhk
Cc: daniel veillard com

> On Thu, May 22, 2008 at 10:12:22AM +0000, dhk wrote:
> > Dan,
> >
> > I am working on a function to find a node in an xml document
> and thought
> > it would be useful for the tree library. Do you know how I
> can submit
> > it for review? Right now it only finds an element node, but I
> intend to
> > expand it to find other node types.
>
> hum, use the mailing list, send the patch as an unified diff,
>
> > The motivation for this function was that when building a tree
> there
> > didn't seem to be an easy way to find a particular node in the
> document.
> > In my case I wanted to get an xmlNodePtr to a tag called
> > with specific value. That way I could easily
> add siblings.
> >
> > Let me know if you're interested.
>
> What I don't know is why you're trying to reinvent XPath ?
> Soon you will find that
> - multiple node may match your criteria so what you want is a
> node set
> - you want to extend your queries
> creating a new function each time just doesn't work from an API
> perspective. Then you need to define exact semantic ... basically
> you will find you need to interpret a query ... i.e. reinventing
> the XPath wheel.
>
> Daniel
>
> --
> Daniel Veillard | libxml Gnome XML XSLT toolkit
> http://xmlsoft.org/daniel veillard com | Rpmfind RPM search
> engine http://rpmfind.net/
> http://veillard.com/ | virtualization library http://libvirt.org/
>


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