in reply to xml processing line-by-line

Depending on the speed of the parser and how much speed matters you could parse it in an eval and catch the exception (or check for errors however XML::LibXML handles them).

You also have other options, could the sender append an EOF or other component to the message to indicate the xml is done? XML Isn't line oriented and can be rather complex, you want to avoid being in the business of parsing it if at all possible (unless you're writing a parser...)

Replies are listed 'Best First'.
Re^2: xml processing line-by-line
by jczeus (Monk) on Jul 24, 2007 at 14:52 UTC

    1.) Do you mean "parse it until there are no more errors"? I thought of that, too. But there can be errors even when the document is complete: when it doesn't follow the DTD, for instance.

    2.) Again, I thought of that, too. ;-)
    But if the sender forgets this, the server appears to hang and eats more and more memory (as more data comes in).

    The best approach seems really to be a content-type including the length at the beginning (before the document itself).

    This way it would also be easy to use a different format, e.g. YAML, without having to guess it.