Text file to XML representation

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Oct 21 12:43:35 CEST 2009


kaklis at gmail.com a écrit :
> Hello,
> I would like to make a program that takes a text file with the
> following representation:
> 
> outlook = sunny
> |   humidity <= 70: yes (2.0)
> |   humidity > 70: no (3.0)
> outlook = overcast: yes (4.0)
> outlook = rainy
> |   windy = TRUE: no (2.0)
> |   windy = FALSE: yes (3.0)
> 
> and convert it to xml file for example:

(snip xml)

> Is there a way to do it?

More than one. But I'd stronly suggest something like PyParsing + 
ElementTree.

PyParsing : http://pyparsing.wikispaces.com/

ElementTree : is now in the stdlib, so refer to the FineManual





More information about the Python-list mailing list