[xml] parser context reuse

For the benefit of the list I'll summarise the conversations Daniel and
I had earlier about how to reuse parser contexts in libxml2.

The parser context should be initially created with xmlNewParserCtxt().
This is currently only available via parserInternals.h, but Daniel
intends to move it to parser.h with the other functions.

Once initialised, the context can be reused with different types of XML
input (memory, file etc.) by using the xmlCtxtReadxxx() functions. 

I actually reduced my code size by quite a bit, as all the common stuff
was done in one place.

xmlCtxtReadDoc and xmlCtxtReadMemory are very similar, except
xmlCtxtReadDoc doesn't require a length and will stop processing at a
null terminator.  Also xmlCtxtReadDoc takes a const xmlChar * for legacy
reasons, but it can just be casted to const char *.



Graham Bennett

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