[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

using if block_given? method.

dare ruby

12/12/2007 3:45:00 AM

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-....

6 Answers

Robert Klemme

12/12/2007 7:55:00 AM

0

On 12.12.2007 04:44, dare ruby wrote:
> 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.

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

Phrogz

12/12/2007 3:01:00 PM

0

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/22fe37...

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.

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

dare ruby

12/13/2007 3:05:00 AM

0

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.


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

Robert Klemme

12/13/2007 8:32:00 AM

0

2007/12/13, dare ruby <martin@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

12/13/2007 8:48:00 AM

0

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 <martin@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-....

Robert Klemme

12/13/2007 9:10:00 AM

0

2007/12/13, dare ruby <martin@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.

robert

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