lucas-ruroken
New Member
I have a TLS/TCP connection to a server that's serving XML documents as a stream of documents. At any time, the stream may have:[*]a partial document (e.g. \[code\]<doc1>one\[/code\])[*]a complete document (e.g. \[code\]<doc1>one</doc1>\[/code\])[*]a complete document and a partial document (e.g. \[code\]<doc1>one</doc1><doc2>\[/code\])[*]multiple documents, etc. (e.g. \[code\]<doc1>one</doc1><doc2>two</doc2>\[/code\])When I read from the stream, I just append read data to an "unparsed" buffer, then attempt to parse the buffer with \[code\]simplexml_load_string\[/code\]. (1) is ok (fails), and (2) is ok (works), my problem is, of course, (3) and (4) fail with extra data. I don't really have a way of saying to the parser "just parse the first X characters" (or use substr) since that would require actually parsing the XML. The documents are, of course, a lot more complex than the examples. Is there any way to:[*]make simplexml_load_string ignore the extra data and have it return a document AND the number of characters it consumed from the string (so I can do buffer manipulation), or[*]use some other parser/conventionThanks.