Re: [xml] Beginner's question about xPath



On Wed, Jun 29, 2005 at 03:39:12PM -0400, ABeylin axsone com wrote:
Hi,

I cannot figure out how to use xPath without loading the entire XML into
memory.

  You can't use XPath on a partial tree by default. Nothing replaces
taking at least 15mn to read about a subject before doing any code about it:
    http://www.w3.org/TR/xpath#predicates

  An XPath can potentailly access any part of a tree, and there is no
garantee of sequentiality.

Let me start of by saying that the document is stored in a proprietary
format, so I have to use our functions to read the data from the files.

  Doesn't sounds good, you are starting with an environment none of us
can help with in case of troubles.

I would like to use xPath without having to load entire XML into memory,
though if it's absolutely required, it will be done.
I looked at the samples on this page:
http://www.xmlsoft.org/examples/index.html#XPath, but it seems that they
load entire files into memory.  Is there a way to feed xPath memory,
much like it is possible to do this for sax parsing (using
xmlCreatePushParserCtxt)?

  Libxml2 has ways to select nodes based on XPath subset in a streamable
fashionor operate with xpath on a subtree. But since you don't give any 
informations about what you really want to achieve, the canonical answer is

  "No, unrestricted XPath operations requires the full tree"

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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