[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: xml in Ruby

paul vudmaska

10/2/2003 5:11:00 PM

>>>
--------
From: Erik Terpstra <erik@terpnet.nl>
Date: Fri, 3 Oct 2003 00:26:52 +0900
References: 83448
In-reply-to: 83448
Last year I made a quick hack that could do something
like that.
I didn't have much experience with Ruby back then, so
it is a quick and
very dirty solution. But the following works:


require 'XML'

y = XML %{
<employees>
<employee>
<name>Joe</name>
<age>28</age>
<department>

<name>Engineering</name>
</department>
</employee>
<employee>
<name>Ken</name>
<age>26</age>
<department>

<name>Engineering</name>
</department>
</employee>
</employees>
}

puts y.employees.employee[0].age
y.employees.employee[0].age = '9'
puts y.employees.employee[0].age

y.employees.employee.each do |employee|
puts "name: #{employee.name}, age:
#{employee.age}"
end
--->

for my third cent, the above syntax 'just makes since'
to me. What could be more semantic than employee.name
without resorting to write your own class/accessors
for it? What's wrong with that being a fundamental
data acess fascility? call me crazy

:pv



__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping...

1 Answer

Chris Morris

10/2/2003 5:41:00 PM

0

paul vudmaska wrote:

>for my third cent, the above syntax 'just makes since'
>to me. What could be more semantic than employee.name
>without resorting to write your own class/accessors
>for it? What's wrong with that being a fundamental
>data acess fascility? call me crazy
>
The point of contention seems to be whether or not this is included in
the core language vs. a library, right? How does the Ruby community as a
whole benefit from core inclusion? What's not satisfying to you about
this solution being contained in a library?

--

Chris
http://clabs....