Re: [xml] libXML2



2005/9/17, Deepak Venkataraman <deepakv hotmail com>:
I am using libXML2 (2.6.x) and have a few questions:

It's always best to mention exactly what version you are using, since
even minor releases can differ quite a lot.

- LIBXML_TEST_VERSION: can this exit the application or does it simply print
a warning?

It will never exit the application. I think it prints a fatal error
message if major versions differ, and a warning if the minor versions
differ. Someone correct me if I'm wrong.


- xmlCleanupParser(); may this be called only once from within an
application or can it be called within threads as well? No, let me rephrase:
is this thread-safe?

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

"Calling this function should not prevent reusing the library but one
should call xmlCleanupParser() only when the process has finished
using the library or XML document built with it."

Note "process", not "thread". Also see http://xmlsoft.org/threads.html.


- I try to assign a string like:
  mdolinktarget = (char *)xmlNodeListGetString(doc,
tmp_node->xmlChildrenNode, 1);
  and pass it as a reference to main but when I print it the string is
empty, I have to instead do:
  strcpy(mdolinktarget,(char *)xmlNodeListGetString(doc,
tmp_node->xmlChildrenNode, 1));
to make it work. Do you know why?

There's no way for us to know why your code won't work as your expect
unless you give us a more complete example. And what do you mean "pass
as a reference to main"? That doesn't make sense and it makes me think
you're doing something wrong that is not related to libxml2. Are you
doing this in C or C++?

The problem is the first way we have now way knowing how long these buffers
need to be;

xmlNodeListGetString() returns a pointer to the allocated string, as
stated in the documentation:
http://xmlsoft.org/html/libxml-tree.html#xmlNodeListGetString. What
more do you need?

Get back with a minimal example of the problems you're having, and I
might be able to help you more :)

Best regards,
Aron



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