From: Robert Klemme Date: 2009-03-26T05:16:53+09:00 Subject: Re: Parsing xml On 25.03.2009 19:24, Jason Roelofs wrote: > Regex is not stateful, thus you can't use it to parse XML. Oh there > are ways to hack yourself around some limitations and get some > results, but you are going to spend a TON of time making very > unreadable Regex that will die at the presense of slightest malformed > XML. Your boss obviously has no idea what he's talking about. If > anything, use REXML because, as another poster said, it's a part of > Ruby and not an external library. Funny as it goes, REXML is actually named that way because it uses regular expressions internally. :-) But of course you are right: there is no easy straightforward way to use a regular expression to properly parse an XML document. The best you can probably do is to match tags and thus split the document in chunks which are either tags or text which can be used to do build up a nested structure etc. - in other words: reinvent the wheel. > If your boss makes these kind of requests often, you should probably > go looking for another job, IMO +2 Cheers robert