Ricko M
Ricko M

Reputation: 1784

Pass character stream to libxml2

I have a XML document which is received as a character stream. I wish to parse this using libxml2. Well one way would be to save it as an .xml and then open it using one of the libxml2 API's. Is there a way i can directly build a tree on this stream and parse it ?

Env is purely c++/c.

Cheers!

Upvotes: 1

Views: 855

Answers (2)

bstpierre
bstpierre

Reputation: 31206

Try xmlCtxtReadFd or xmlCtxtReadIO depending on your context.

Upvotes: 1

nmichaels
nmichaels

Reputation: 50971

You can use xlmCtxtReadFd from parser.h. There's also xmlCtxtReadMemory, if you would rather use a block of memory than a stream.

Upvotes: 2

Related Questions