> -----Original Message-----
> From: Alex Liebowitz [mailto:stopm / attbi.com]
> Sent: Friday, April 12, 2002 11:44 AM
> To: ruby-talk ML
> Subject: Couple of questions about XML modules
> Importance: High
>
>
> I am considering doing a fairly large project with Ruby and XML, and I'd
> like a summary of the benifits and downsides of the various available
> modules from someone with experience.  My project will generate
> perfect XML
> and then read it in subsequently, so I don't need to worry about
> validation.
> Ease of use is a big priority, and speed is not terribly important.

If you're not validating, then I would suggest looking at REXML. The
benefits are that, like Ruby, it is easy and intuitive to use.  The
downside (which may not matter) is that it does not implement the W3C DOM
API.  Personally, I don't see this as an issue; I prefer the REXML API.

If you haven't already, check out www.rubyxml.com, for a rather lengthy
list of all the XML-related Ruby libs.

>
>
> My next problem is:  I can't seem to find any documentation on
> XMLparser, so
> if anyone could give me an example of how to break this XML data:
>   <A>
>     foo
>     <B>bar</B>
>     baz
>   </A>
>   <C>
>     gak
>   </C>
> ...into this array:
>   [["A", "foo", ["B", "bar"], "baz"], ["C", "gak"]]
>
> ...using XMLparser, I would be much obliged.


There's an article here:
http://www.xml.com/pub/a/1999/09/expat/

about using expat.  The example code is in C, but it does kinda what you
want.
parse XML, and react to each element as it's parsed.

I believe you need to override startElement and endElement in the ruby
version.


James

>
>