What library/package to use for parsing XML?

Chris Green cl at isbd.net
Tue Jan 31 03:52:22 EST 2017


Irmen de Jong <irmen.NOSPAM at xs4all.nl> wrote:
> 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]
> 

Thanks, it was the ElementTree bit I didn't know.  Searching for
'Python XML' produces so many hits it's difficult to see what's
necessary/best.


-- 
Chris Green
·



More information about the Python-list mailing list