 <p>You can do exactly the same thing in C++:</p> <pre><code>std::ifstream reader( xmlInputStream.c_str() ); if ( !reader.is_open() ) { // error handling here... } std::string xml; std::string line; while ( std::getline( reader, line ) ) { xml += line + '\n'; } </code></pre> <p>It's probably not the best solution, but it's already fairly good. I'd probably write something like:</p> <pre><code>std::string xml( (std::istringstream_iterator&lt;char&gt;( reader )), (std::istringstream_iterator&lt;char&gt;()) ); </code></pre> <p>(Note that at least one set of the extra parentheses are needed, due to an anomaly in the way C++ would parse the statement otherwise.)</p> <p>Or even:</p> <pre><code>std::string readCompleteFile( std::istream&amp; source ) { return std::string( std::istringstream_iterator&lt;char&gt;( source ), std::istringstream_iterator&lt;char&gt;() ); } </code></pre> <p>(Look ma, no variables:-)!) Both of these solutions preserve the newlines in the original file, so you don't need to put them back in after reading.</p>