libxml - Load xmlDoc from raw data

Go To StackoverFlow.com

1

I have a char* buffer of data that I want to parse as XML in libxml2.

How would one go about that?

Currently I am using it to open the file automatically by calling a file name, but it would be nice to have more functionality.

Currently I do it like this:

xmlDocPtr doc = xmlParseFile("data/foo.xml");

However I have a resource system that gives me access to the raw data, so my more preferred method would be:

resource_base_ptr res = load_resource("data/foo.xml");
xmlDocPtr doc /*= some_function(res->raw_data) */;
2012-04-03 21:54
by DubyaDubyaDubyaDot


1

You need to use xmlReadMemory()

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

2012-04-03 23:14
by dbeer
That works beautifully, thank you - DubyaDubyaDubyaDot 2012-04-03 23:23
Ads