http://www.perlmonks.org?node_id=420406


in reply to Incremental parsing of multiple XML streams?

One of the major selling points of XML is that it is well structured: an XML parser can determine if the data is well-formed.

It sounds like the right way to go would be to use a buffer that captures the XML as it comes in, then when it gets the closing tag that matches the first opening tag, cut the buffer off and send it to be parsed.

Perhaps the reason you're having a hard time is because you're fighting all of the things that have been done to make XML in Perl easy and reliable.


--
Spring: Forces, Coiled Again!
  • Comment on Re: Incremental parsing of multiple XML streams?

Replies are listed 'Best First'.
Re^2: Incremental parsing of multiple XML streams?
by nothingmuch (Priest) on Jan 08, 2005 at 14:13 UTC
    If that's the case, I can just wait for </xml>, and then parse that string up.

    But I need a SAX like interface, generating events for data, as it enters. I'm not concerned about the XML's tree at the end, because I need it's data parsed (as far as possible), as it arrives. The opening of an element concerns me before it's end is even on the data stream, let alone actually parsed.

    -nuffin
    zz zZ Z Z #!perl