I need to parse standard XML structures coming from a TCP/IP connection. The data is kept as a string variable. This means that in any given time the data in my hand can be incomplete (an incomplete XML structure), or a complete XML structure with incomplete leftover (the beginning of the next XML structure).
Most of the structures are not 'empty':
<Message>
<Param1 value = "val1"/>
<Param2 value = "val2"/>
</Message>
But there are also 'empty' ones:
<Message status="ack" />
So just searching for </Message>
and making a split there is not good enough.
How can I part the complete structure from the next partial structure? Is there a cleaner solution other than creating my own state-machine for this and checking byte by byte?