Hi, I wrote a program which performs certain operations on an
XML file (like reading attributes, setting their values, adding/deleting nodes
etc) and in case of any modification, writes it back to the file. The node on
which the operation is to be performed is specified using XPath. So before each
such operation, I was using the API calls xmlParseFile() to create the DOM tree
and xmlXPathNewContext() to create a new context. After the operation was done
with, I was calling xmlSaveFormatFile(), xmlXPathFreeContext() and xmlFreeDoc()
in that order to save the change to the XML file and to free the context and
document handles. This was working fine but was slow because of the overhead of
creating/freeing the handles before/after each operation. To make it run faster, I changed my program to create the
DOM tree and the context just once at the beginning, and free them at the end
of the program (along with saving the DOM tree to the XML file). Throughout my
program I use the handles for document and context created at the beginning for
any operations performed on the tree. This seems to work (the outputs I got are
correct so far), but throws some error/warning messages at the console. The
messages are:
I looked at the source code and line #11683 in file xpath.c
is the definition for the function xmlXPathEvalExpression(). Somehow it finds
the context pointer to be NULL and shows message #1. I can’t understand
how it’s NULL since my program does not modify the context pointer
explicitly. I searched for the other two messages in the source files but could
not locate them. How can I get rid of these messages? Any help will be
greatly appreciated. Thank you. Pinaki |