What library/package to use for parsing XML?

Irmen de Jong irmen.NOSPAM at xs4all.nl
Mon Jan 30 16:20:08 EST 2017


On 30-1-2017 18:58, Chris Green wrote:
> I want to parse some XML data, it's the address book data from the
> linux program osmo.  The file I want to parse is like this:-
> 

[snip]

> 
> I basically want to be able to extract the data and output in other
> formats - e.g. write to a Sqlite3 database and/or CSV.
> 
> So what do I need to import (and probably install first) to do this?

No need to install anything. Python has batteries included.

Parse your XML with xml.etree.ElementTree
    [https://docs.python.org/3/library/xml.etree.elementtree.html]
Read/write CSV with csv
    [https://docs.python.org/3/library/csv.html]
Put stuff in sqlite3 database and query it using sqlite3
    [https://docs.python.org/3/library/sqlite3.html]


-irmen




More information about the Python-list mailing list