XML to dictionary?
Randall Hopper
aa8vb at yahoo.com
Fri Jan 7 09:33:30 EST 2000
Randall Hopper:
|Matt Gushee:
| |from pyxie import File2PYX # PYX is the notation pyxie uses for
| |import string # parsed XML
| |
| |f = File2PYX('hithere.xml')
| |data = f.read()
| |f.close()
| |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. :-)
In case it wasn't obvious to some, the fix is to change split to:
data = string.split(data, '\n')
--
Randall Hopper
aa8vb at yahoo.com
More information about the Python-list
mailing list