From: "Ing. Damiano Bolla" <[EMAIL PROTECTED]>
> Maybe I did not make clear the solution I used.
>
> It IS possible to parse an XML stream coming from a socket WITHOUT knowing
> its length.

Not without making some assumptions about what the XML looks like.


> What you need to do (I can post the code if you wish) is understanding the
> logical end of the
> XML stream (the logical end is whan you go back to level Zero of the XML
tree).
>
> To do this you need to use a SAXDriver and use a custom ContentHandler
class.
> It works.

Oh you mean to hack it to ignore everything after the last endElement()
event then force the parser to abort by throwing a SAXException?

It kinda works but its cheating really, since there may be comments and
processing instructions that you might be hiding; this also may make the
next document invalid.

e.g.

<?xml version="1.0"?>

<foo>1</foo>

<!-- bottom of doc 1 -->

<?xml version="1.0"?>

<foo>2</foo>


If you stopped parsing as soon as you hit the </foo> tag then the comment at
the end of the document will appear at the start of the next document, which
is invalid as the <?xml ?> declaration has to the first. So the 2nd document
won't parse.

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to