split xml stream
Posted: Fri May 11, 2007 8:00 am
Dealing with jabber protocol, I want to get the sequence of separate xml statements from continuous xml stream, which is coming from server.
I can net-receive a buffer, consists of one xml statement and a start part of tne next statement.... or I can get a partial single xml statement...
In common, to handle this, I want to get all closed statements from the string buffer and leave the last unclosed (if exists) in the string buffer for appending further net-receive results to it.
As I can see, xml-parse can get the stream of statements and also survives unclosed xml statements at the end of the stream. But how can I find the point where I must to split buffer into "already closed statements" and "not yet closed last statement" parts?
If there is no a standard way for this, probably it will be possible to extend xml-parse function so it will return some positioning informaition and also a signal that the final upper-level xml statement is unclosed?
I can net-receive a buffer, consists of one xml statement and a start part of tne next statement.... or I can get a partial single xml statement...
In common, to handle this, I want to get all closed statements from the string buffer and leave the last unclosed (if exists) in the string buffer for appending further net-receive results to it.
As I can see, xml-parse can get the stream of statements and also survives unclosed xml statements at the end of the stream. But how can I find the point where I must to split buffer into "already closed statements" and "not yet closed last statement" parts?
If there is no a standard way for this, probably it will be possible to extend xml-parse function so it will return some positioning informaition and also a signal that the final upper-level xml statement is unclosed?