In a GTK application, I'm using xmlParseFile()
from libxml2. However, that function can only read local files. How can I instead make it use the GIO framework, so that it can read remote files as well?
The simplest way is probably to use something like g_file_load_contents()
to read the entire file into memory, then call xmlParseMemory()
to parse that. However, I'm looking for a "nicer" solution which ideally streams the data (to avoid keeping the entire data in memory); possibly by connecting a GInputStream
to libxml2?
Code examples welcome. I would guess this is a common use case, so collecting an exhaustive list of good implementations here might be useful.