On Jan 19, 2005, at 03:58, David Rock wrote:
For me, it seems that the way you are supposed to interact with an XML DOM is to already know what you are looking for, and in theory, you _should_ know ;-)
Indeed. The problem is, even if I know what I'm looking for, the problem remains that given the following document,
<foo> <bar>baz</bar> </foo>
If I want to get "baz", the command is (assuming a DOM object has been created):
doc.documentElement.getElementsByTagName("bar")[0].childNodes[0].nodeVal ue
Quoting from memory there, it may not be entirely correct. However, the command has more characters than the document itself. Somehow I feel it'd be a bit more elegant to use:
doc["bar"]
(or depending on the implementation, doc["foo"]["bar"])
Don't you think?
Still, I can't help wishing I had a simple way to create a dict from a DOM. From a Python perspective, that seems more "Pythonic" to me as well. I guess it's just a different way of looking at it.
I can't help but think that from the perspective of any other language, that would feel more [language]-ic as well ;)
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?"
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor