[jdev] parsing xml (xmpp) with ruby

Eric Will rakaur at malkier.net
Wed Oct 1 10:33:44 CDT 2008


On Wed, Oct 1, 2008 at 11:15 AM, Michal 'vorner' Vaner <vorner at ucw.cz> wrote:

> If you take <stream thenamespace etc><first stanza/> and put it into
> first parser and then <second stanza/><third stanza> to second and
> </thind stanza> into another, then you get mess and not data. Or do you
> reuse it in some other way I do not get?

I'm using a SAX parser. It doesn't care about the structure of the
overall document. I build the nodes by myself, a tag at a time.

> When a stanza gets split into two chunks, you get even more mess.

I handle this at the moment, but not in the best way. When my parser
gets to a partial stanza it reads and processes up to the partial
part, it does one of two bad things. The first one is when i get half
a tag or something, and it raises an exception saying it's invalid
XML. The second one is when it lands in the middle of an open tag, but
everything is well-formed, but there's no closing tag. In this case it
parses as far as it can, but without closing tags (which is where I
fire my events) it doesn't DO anything, so it appears to ignore it...
I'm not sure how to fix this.

> This is my code when data come. It is C++ and Qt, but you might see:
>
> source.setData( text );
> reader.parseContinue();

REXML doesn't have this. There's no way to change the source except to
make a new parser instance.

> --
> "Don't worry about people stealing your ideas.   If your ideas are any good,
> you'll have to ram them down people's throats."
>        -- Howard Aiken
>
> Michal 'vorner' Vaner

-- Eric Will // rakaur --



More information about the JDev mailing list