[jdev] parsing xml (xmpp) with ruby

jlist jlist9 at gmail.com
Sun Sep 28 23:52:49 CDT 2008


I also find XMPP particularly difficult to parse.

In the case of a TLS connection, there's also the switch
from plain text to TLS...

I'm also coming to think that the best (or easiest) way
could be to use a SAX parser to parse out the stanzas, then
use a DOM parser for easy access to the attributes. However,
this may not handle the TLS's case though. I haven't looked
into the details but I suspect I need to handcraft the SAX
parser for the <stream> tags just to handle this scenario.

Jack

Saturday, September 27, 2008, 12:28:21 PM, you wrote:

> Hello World,

> I am writing an XMPP (Jabber) server in Ruby. XMPP uses XML for its
> protocol. This means I have to do a good deal of XML parsing, in Ruby.

> Right now I am using REXML to parse the individual stanzas as they
> come in. However, in order to do this without REXML complaining of
> "multiple root elements" (that is, XMPP is streaming XML over a TCP
> socket, so I only get the root element once) I have to wrap every
> incoming chunk of XMPP with my own <root/> tag, and then ignore that
> after REXML parses it. I am currently unhappy with this approach.






More information about the JDev mailing list