Is there a way to tell the XML/SGML parser to stop parsing after finding an end tag?
I am trying to parse XMPP which in the beginning of the network session sends an XML fragment that is not closed:
<stream:stream from='im.example.com' id='t7AMCin9zjMNwQKDnplntZPIDEI=' firstname.lastname@example.org' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'> <stream:features> <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'> <required/> </starttls> </stream:features>
Notice stream is left open. I am able to use the call(…) option of sgml_parse/2, and it processes the elements, but I need the parsing to end when it reaches
<stream:features>, otherwise the parser keeps waiting for the
</stream:stream> (because the tcp stream needs to be left open). I can’t use the `content_length(…)’ option of sgml_parse/2 because the length is variable.