Skip to content

Simplest way to write an XML document to a char * buffer. #549

Answered by zeux
jmccabe asked this question in Q&A
Discussion options

You must be logged in to vote

Either of these two are more or less how this is intended to work, yes. pugixml doesn't have a built-in function to do this; I'm not sure what exactly rapidxml::print does in case the amount of bytes it needs to write is larger than the size buf has allocated, but either way pugixml expects you to manage this in the writer implementation yourself (for example, by flushing chunks to the external output as the pre-allocated memory gets exhausted, or by reallocating memory to fit). The specific example implementation of xml_write_buf doesn't handle this safely (it's fine if it's just an example to illustrate the concept of course).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jmccabe
Comment options

Answer selected by jmccabe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants