From: Jason Roelofs Date: 2009-03-26T02:57:48+09:00 Subject: Re: Parsing xml On Wed, Mar 25, 2009 at 1:52 PM, Peter Zotov wrote: > Quoting "Arun Kumar" : > >> Peter Zotov wrote: >>> >>> Quoting "Arun Kumar" : >>> >>>> Hi, >>>> Is there any way in Ruby to parse an xml file without using REXML or any >>>> other libraries. >>> >>> Of course. You can write a finite state machine, read XML from file >>> and parse as you want. >> >> Thanks. Can u please give me details of it. > > It is described nicely in Wikipedia: > http://en.wikipedia.org/wiki/Finite_state_machine > > As a clue, I can recommend you define following states: "text", "opening > tag", "tag attribute", "tag attribute value", "closing tag". E. g. when you > are in "text" state and get "<" symbol at input sequence, you change state > to "opening tag" or "closing tag"... > I still have one question: why you don't use REXML? > > -- >  WBR, Peter Zotov > > Better question: Why *wouldn't* you want to use an existing library? You'd have to spend months on your own before it even starts to make sense to use such a custom solution over an existing, tested, and heavily used library like libxml or nokigiri (and to be fair, Hpricot::XML, though it's more for HTML parsing than XML). Jason