Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using if block_given? method.

2 views
Skip to first unread message

dare ruby

unread,
Dec 11, 2007, 10:44:50 PM12/11/07
to
Hi everybody,

I have created a simple parser. i have used @tag method to store tag
start and tag end. my requirement is how to read attributes and its
values when it has more than one attributes like,
This is the input string,

<aaa size="100" name="xxx"></aaa>

I need output like

tag start : aaa
attribute name: size
attribute value : 100
attribute name : name
attribute value : size
tag end : aaa

i have read character by character and i have executed tag start and tag
end.
i have read attribute naes and values also but my program actually not
displaying it properly like my output is

tag start : aaa
attribute name : name
attribute value : size
tag end : aaa

my program is actually rewritting the old ones. i have used @tag to
store tag start and tag end and i have called thosed using if
block_given? method. i have used parse_attribute, parse_attribute_value
method to read attribute names and values. How tyo make it work properly
when multiple atrribute names and values are given.

Thanks in advance
--
Posted via http://www.ruby-forum.com/.

Robert Klemme

unread,
Dec 12, 2007, 2:54:30 AM12/12/07
to

I am not really sure what you are asking here but in case you are
parsing XML: did you consider using an XML parser, for example REXML in
stream mode?

robert

Gavin Kistner

unread,
Dec 12, 2007, 10:01:03 AM12/12/07
to
dare ruby wrote:
> I have created a simple parser. i have used @tag method to store tag
> start and tag end. my requirement is how to read attributes and its
> values when it has more than one attributes like,
[snip]

Answer here:
http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/87b5fb008b22b453/22fe3736ee69efbf

I suggest you stop using ruby-forum until it is fixed, and instead use
another source that lets you see the answers people are providing.

dare ruby

unread,
Dec 12, 2007, 10:05:20 PM12/12/07
to
sorry Gavin, please if you are not intrested in topic please dont reply.
iam new to ruby so i should do what ever i can do to complete my task.so
iam looking for all the sources to perform well.

Sorry Gavin.

Robert Klemme

unread,
Dec 13, 2007, 3:32:21 AM12/13/07
to
2007/12/13, dare ruby <mar...@angleritech.com>:

> sorry Gavin, please if you are not intrested in topic please dont reply.
> iam new to ruby so i should do what ever i can do to complete my task.so
> iam looking for all the sources to perform well.

Did you actually *read* and *understand* Gavin's message? His was an
attempt at helping you getting better feedback.

robert

--
use.inject do |as, often| as.you_can - without end

dare ruby

unread,
Dec 13, 2007, 3:47:33 AM12/13/07
to
sorry robert and gavin........

sorry......

lets continue our discussion

Actually robert i was not supposed to use REXML or any other inbuilt
classes in my task.

Robert Klemme wrote:
> 2007/12/13, dare ruby <mar...@angleritech.com>:
>> sorry Gavin, please if you are not intrested in topic please dont reply.
>> iam new to ruby so i should do what ever i can do to complete my task.so
>> iam looking for all the sources to perform well.
>
> Did you actually *read* and *understand* Gavin's message? His was an
> attempt at helping you getting better feedback.
>
> robert

--
Posted via http://www.ruby-forum.com/.

Robert Klemme

unread,
Dec 13, 2007, 4:09:58 AM12/13/07
to
2007/12/13, dare ruby <mar...@angleritech.com>:

> sorry robert and gavin........
>
> sorry......
>
> lets continue our discussion
>
> Actually robert i was not supposed to use REXML or any other inbuilt
> classes in my task.

Then you should show some code you have issues with. With the bits
you provided nobody can really come up with an answer.

0 new messages