Re: [xml] Query regarding re-using parser context for SAX parsing



On Fri, Mar 28, 2008 at 06:50:32PM +0530, Nagesh wrote:
Hi All,

       Is there any way, I can re-use the already created parser context
(ex: xmlCreateMemoryParserCtxt) to perform SAX parsing of more than one xml
document without freeing and creating the parser context again. I tried
using xmlSetupParserForBuffer( ), but apparently it handles only the case in
which the encoding of the XML document is UTF-8. Any other encoding is
currently not supported by xmlSetupParserForBuffer( ). 

  create your XML parser context, then use xmlCtxtReadMemory()
(assuming parsing from memory) for each document with the same parser
  http://xmlsoft.org/html/libxml-parser.html#xmlCtxtReadMemory

The xmlCtxtRead... functions uses xmlCtxtReset() to cleanup existing state
left from previous parsing

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]