[jdev] parsing xml (xmpp) with ruby
Michal 'vorner' Vaner
vorner at ucw.cz
Wed Oct 1 10:15:11 CDT 2008
Hello
On Wed, Oct 01, 2008 at 11:04:11AM -0400, Eric Will wrote:
> On Wed, Oct 1, 2008 at 8:21 AM, Michal 'vorner' Vaner <vorner at ucw.cz> wrote:
> > You can not use a new parser every time. You need it to know the
> > beginning of the stream.
>
> Why? It works fine without knowing it. How can I reuse the same parser
> when the source changes?
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?
When a stanza gets split into two chunks, you get even more mess.
> That is, I have to do parser = REXML::Parsers::SAX2Parser.new(source)
> every time, and feed it the source. Is there a way to feed an existing
> SAX2Parser a new source?
This is my code when data come. It is C++ and Qt, but you might see:
source.setData( text );
reader.parseContinue();
--
"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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <https://www.jabber.org/jdev/attachments/20081001/36457b7a/attachment-0003.pgp>
More information about the JDev
mailing list