Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse a XML string instead of XML doc in c using libxml2 library

All the examples in libxml2 documentation libxml tutorial are mentioned using external XML files. What if I need to parse a string with XML content in it? Is it really possible in libxml2 C library, or the only solution would be taking the string saving it to the file and sending that file name as argument to the below function. But it would seriously effect the performance.

doc = xmlParseFile(docname);

Are there any inbuilt functions in libxml2 to parse character arrays?

like image 315
forum.test17 Avatar asked Sep 23 '12 18:09

forum.test17


1 Answers

You can use xmlParseDoc(), which will take a null terminated string (of xmlChar / unsigned char) and parse it exactly as if it were read from a file using xmlParseFile().

like image 124
Joachim Isaksson Avatar answered Oct 13 '22 19:10

Joachim Isaksson