Search code examples
c++xercesxerces-c

Xerces C++: how do I read data from a stream as it arrives?


I need to read data from my own stream and parse it using Xerces/C++ (SAX or SAX2) as it arrives. I've seen Xerces Java FAQ on this, but Java and C++ APIs don't really seem to match; at least, I can't see a DefaultReaderFactory class in C++ API. So, is non-buffered reading from a stream supported in C++ API? If yes, I would be grateful for a code example or an advice on how to port the Java approach to C++.


Solution

  • I think you want to use SAXParser::parseFirst(InputSource, token) and parseNext(token), either MemBufInputSource if you have the data laying in memory somewhere and can point to it, or by implementing your own InputSource.