Re: [xml] Reusing xmlParserCtxt



On Wed, Oct 11, 2006 at 11:16:21AM +0530, harbhanu wrote:
Hi,

Can we reuse the context created(by call to xmlCreateMemoryParserCtxt)
inside xmlSAXUserParseMemory, to parse another document..??

 

What I have observed that some information regarding current parsing is
stored in the xmlParserCtxt structure.

So, once parsing of a document is done, can the same context be safely
reused to parse another document.?

 

Is there a reset API to bring back the used context to the initial state?

  Initial no, the reset is complete, inputs included:
  http://xmlsoft.org/html/libxml-parser.html#xmlCtxtReset
Once you have started parsing you cannot go back on input, it's a new parse.

The functions xmlCtxtRead... are specifically designed for reuse on multiple
parse:

  http://xmlsoft.org/html/libxml-parser.html#xmlCtxtReadMemory

Trying to reuse contexts with other functions is not garanteed, simply because
I didn't tested those, you will have to try and possibly debug.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]