XML vs Python?

N. Thomas nthomas at cise.ufl.edu
Tue Jan 14 17:25:57 EST 2003


...or rather "XML's data structures vs Python's data structures"

So I prototyped a program that keeps its data stored in an XML document,
via PyXML's DOM API. Whenever I want to view/add/remove/change data, I
traverse along the XML nodes, and do what I want with it. It took a
while to get used to DOM, but after a bit, I got the hang of it.

[time goes by]

I then realized that I could have instead stored my data in a Python
data structure (nested lists, dictionaries, etc.), and have some
function (i.e. p2xml() and xml2p()) that would convert to and from XML.

Ultimately, the data will be saved in XML format, but it would be much
easier to traverse/manipulate in my program.

Are there any issues that I should be aware of regarding this? I mean,
are there situations where is it better to save one's data in XML
internally as opposed to using the language's native structures, and
exporting to/from XML?

thanks,
thomas

-- 
N. Thomas
nthomas at cise.ufl.edu
Etiamsi occiderit me, in ipso sperabo




More information about the Python-list mailing list