XML to dictionary?
Matt Gushee
mgushee at havenrock.com
Fri Jan 7 09:58:52 EST 2000
Randall Hopper writes:
> Matt Gushee:
> |data = string.split(data)
> |
> |dict = {}
> |for line in data:
> | if line[0] = '(': # '(' at the beginning of the line in
> | # PYX indicates an element
>
> Pyxie is a good tool. But just to pick nits, using string.split isn't safe
> with Pyxie output. :-)
>
> Consider:
>
> <?xml version = "1.0"?>
> <Greeting>
> Wishing You A Merry Christmas!
> From all of us (here at the White House)
> Author: --Unknown
> </Greeting>
>
> string.split gives you a new start tag, attribute, and text element you
> didn't know you had ;-)
Ah. I see what you mean. Well, how about:
data = string.split(data, "\n")
Matt Gushee
More information about the Python-list
mailing list