Quoting "Arun Kumar" <arunkumar / innovaturelabs.com>:

> Peter Zotov wrote:
>> Quoting "Arun Kumar" <arunkumar / innovaturelabs.com>:
>>
>>> 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?
>
> Hi,
>
> The problem is that my boss donot want me to use any libraries to parse
> xml. He also said to use regular expressions to extract the contents of
> an xml tag. Can u please tell me how to do it. I'll be really greatfull.

If you have, for example, this document:
----8<----
<?xml version="1.0" encoding="utf-8"?>
<root>
  <some-tag>some text</some-tag>
</root>
----8<----

you can extract contetns of tag "some-tag" with this (code assumes  
that document lies in "document" variable):

document.match(/<some-tag>(.+?)<\/some-tag>/)[1]

But this will fail at "some-tag" embedded in other "some-tag" and if  
tag will have arguments. Of course, these variants can be predicted  
and added to regexp too, but this will make it very complicated.

Anyway, REXML is not _external_ library to Ruby. It's in stdlib!

--
   WBR, Peter Zotov