From: Austin Ziegler Date: 2003-10-03T21:59:11+09:00 Subject: Re: xml + ruby On Fri, 3 Oct 2003 16:11:46 +0900, paul vudmaska wrote: > As for the conflict with characters in ruby names, unfortunately I > can suggest no obvious solution - maybe use xpath where the easy > way is not acceptable. Also someone mentions 'just getting to the > element he wants' without using a long path. Again, xpath, would > be the direct/best approach perhaps. I think it's more than that. There's a deep division in the XML camp itself as to whether things should be expressed as attributes or child elements: baz The moment you have to deal with an attribute, the x.y notation becomes nearly useless. How do you deal with attributes in that form[1]? The e4x stuff as you've presented it here is also very DOM-oriented, which is fine for smaller XML documents, but assuredly not fine for many other documents -- unless you plan on doing lazy loading. There's further confusion if you had: 123 How would I refer to each individual item: list.item[0] through list.item[2]? If the tag also allowed for CDATA values, there's nothing in the XML spec that would prevent: cdata1cdata2cdata What you've suggested offers no easy way around this. You're far better off not treating XML as pseudo-objects. It's a poor fit, ultimately, and the moment you get anything reasonably complex (like RSS) or having namespace support, or you need a larger document that won't fit into memory entirely as DOM requires, it breaks and you need the more complex API again. -austin [1] I have not looked at the e4x stufff, and I don't intend to; I have too much else on my plate right now. I'm asking practical problems regarding the suggestion made here. -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.10.03 * 08.50.00