in reply to Telnet, XML API, and I/O Buffering

You need to know when the XML has been fully received. There are two general approach.