[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: humanized Xml tree navigation

Hal E. Fulton

7/31/2006 1:30:00 PM

chiaro scuro wrote:
> Does anybody know of a library that allows to go through an xml tree as if
> it were made of normal objects?
>
> I have seen e4x on rubyforge, but it doesn't seem to work. simplexml
> returns
> hashes rather than employing dynamic method calls
>
> What I need to do is to be able to traverse an xml document as in:
>
> * people.each_person {...}
> * people.person[2].name
> * people.person.name #takes the first person
> * people.person.size
>
> etc..
>
> Any suggestion?

I like the idea, but I'm unaware that it's been done
to that level.

Why don't you start with REXML and put a wrapper on it?
Then publish it for everyone to enjoy.

Or do you find REXML too slow for your use?


Hal

1 Answer

Trans

8/8/2006 1:11:00 PM

0


> chiaro scuro wrote:
> > Does anybody know of a library that allows to go through an xml tree as if
> > it were made of normal objects?
> >
> > I have seen e4x on rubyforge, but it doesn't seem to work. simplexml
> > returns
> > hashes rather than employing dynamic method calls
> >
> > What I need to do is to be able to traverse an xml document as in:
> >
> > * people.each_person {...}
> > * people.person[2].name
> > * people.person.name #takes the first person
> > * people.person.size
> >
> > etc..
> >
> > Any suggestion?

It's not really the best way to traverse XML becuase there's some
exceptions --keywords that ruby uses that wouldn't be traverable as
tags, and legal XML tags that you would not be able to use as method
calls.

I'm suprised the the e4x implemention on Rubyforge didn't work at all
--I'll have to look at it, but in any case it is completely
expiremental, and incomplete. For my needs I have moved on to a
Ruby-esque interface instead (http://cherry.rub...).

T.