[jdev] parsing xml (xmpp) with ruby
Remko Tronçon
remko at el-tramo.be
Wed Oct 1 10:45:06 CDT 2008
> 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.
That doesn't really make much sense. Parsing
<document xmlns="bla"><foo>...
in one pass, and parsing
<document xmlns="bla">
and then
<foo>
is something entirely different (foo will have a different namespace).
A SAX parser *does* care about the document structure. The only
difference is that you don't need to parse the whole document before
you know anything about its structure.
Creating a new parser for every piece of data doesn't work. If you
don't understand the difference above, then consider parsing "<foo><"
and then "/foo>" in one step, and consider parsing it with a new
parser. The second chunk will not parse in a new parser. It will parse
if you hand it to an existing parser that already parsed <foo><.
cheers,
Remko
cheers,
Remko
More information about the JDev
mailing list