Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlParseFile vs xmlReadFile (libxml2)

Tags:

c

libxml2

I'm writing some C code using the libxml2 library to read an XML file. There seem to be two different functions for this purpose, xmlParseFile and xmlReadFile, and and I'm not sure of the difference between them (besides the fact that xmlReadFile() takes some additional parameters).

The examples on the libxml2 website sometimes use xmlParseFile and some use xmlReadFile.

So when should you use xmlParseFile and when should you use xmlReadFile? I haven't been able to find anything that explains this.

like image 743
Daniel Avatar asked Jul 29 '26 13:07

Daniel


1 Answers

xmlReadFile() is a bit more powerful as it is able to take an URL instead of a local file path, and allows to specify more options (http://xmlsoft.org/html/libxml-parser.html#xmlParserOption), so I tend to use it instead of xmlParseFile(). That said, if you are parsing a local XML file and not using the parser options, you will be fine with xmlParseFile().

like image 51
Remi Gacogne Avatar answered Aug 01 '26 02:08

Remi Gacogne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!