On 1/28/08, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Senthil Nathan wrote:
> > I would like to how to handle the xpath error gracefully when I use the
> > libxml api,
> > xmlXPathEvalExpression(path, xpathCtx).
> >
> > If I pass a invalid path string to evaluate on the "xpathCtx", it throws
> the
> > error as below and stops there.
> > But I would like to handle that error gracefully and log it accordingly
> and
> > proceed with my application.
>
> What is the reason why you cannot just continue after this error? Just
> call
> xmlXPathEvalExpression() again (with a working expression) and everything
> should be fine.


In my application, when an invalid xpath string is given, during the
xmlXPathEvalExpression( ),
it fails with the error and just stops there. it's not continuing further
and just hangs or stops there.
So, I only need to break the application. Is there a better way to handle,
in case of these xpath errors.

> So, could anyone give me ideas on doing the same? Or is it possible to
> check
> > the xpath expr is valid or not even before
> > calling the libxml api.
>
> You can compile the expression.


So do you mean by calling
xmlXPathCompile (const
*xmlChar*<http://mail.google.com/mail/libxml-xmlstring.html/lxmlChar>*
str) and then xmlXPathCompiledEval
(*xmlXPathCompExprPtr*<http://mail.google.com/mail/libxml-xpath.html/lxmlXPathCompExprPtr>comp,
*xmlXPathContextPtr*<http://mail.google.com/mail/libxml-xpath.html/lxmlXPathContextPtr>ctx)
instead
of xmlXPathEvalExpression( ).
Is that right. But will it not the same error happen here and just stop
there?? Could you please clarify me on this.

Stefan
>

Thanks
Senthil Nathan R
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to