c++ xml chunk data error



I have a xml reader in C++ and I am making a error function or proofer that only sends complete xml trees to the parser. The data is in a char array like



char chunkdata[245];


Then convert it to a string like



String data(chunkdata);


And parse the data. This program will get chunked data at any time and process. The only thing with chunked data is that it sometimes sends incomplete xml trees... So I might only get half of a content in a char array like



<?xml version="1.0" encoding="UTF-8"?>
<note>
<to> Tove</to>
<from>Jani</from>
<heading>Remin


And get a few mil seconds later the rest



der</heading>
<body>Don't forget me this weekend!</body>
</note>


And after processing it would produce two strings and crash the program.


What could I add in my code to either wait to add if not complete... or get only the complete xml trees and leave the remaining to add to the rest when it comes... I tried things like string FIND with string substring which would process then Add the remaining later but it didn't work.. Any suggestions ??? Thank you


No comments:

Post a Comment