[Tutor] Using Beautiful Soup to extract tag names
Ed Singleton
singletoned at gmail.com
Tue Mar 14 16:14:19 CET 2006
I have (unfortunately) received some data in XML format. I need to
use it in Python, preferably as a list of dictionaries. The data is a
flat representation of a table, in the style:
<tablename>
<fieldname1>Some Data</fieldname1>
<fieldname2>Some Data</fieldname>
...
</tablename>
<tablename>
<fieldname1>Some Data</fieldname1>
<fieldname2>Some Data</fieldname>
...
and so on (where tablename is always the same in one file).
It looks like Beautiful Soup would be a good option to quickly change
it into a usable format, but I need to extract the field name (there's
lots and lots of fields) as well as the data, and I can't work out how
to do that in Beautiful Soup.
If anyone can give me some help I'd be grateful, or if they can point
me in the direction of a better solution.
Thanks
Ed
More information about the Tutor
mailing list