Boost has a tutorial on how to load XML from a file. How do I feed it with a string that I either create in code or receive from a user (e.g. with cin
)?
相关问题
- Sorting 3 numbers without branching [closed]
- Illegal to have multiple roots (start tag in epilo
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Creating XML Elements without namespace declaratio
- Class layout in C++: Why are members sometimes ord
- Get Attribute Value From Simple XML Using JQuery /
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
Wrap the string in an
istringstream
.The other answers are non-ideal, because using
istringstream
needlessly copies the entire buffer.As an answer on this question suggests, you could use the deprecated
istrstream
, but as this generates warnings and may be removed in future, a better solution is to use boost::iostreams:This avoids needlessly copying the buffer in the same way
istrstream
did (which can be a considerable problem, if your input buffer is large), and saves you having to write your own stream class.Heres some code that works for me...