Text file to XML representation

Jorgen Grahn grahn+nntp at snipabacken.se
Thu Oct 22 07:56:55 EDT 2009


On Wed, 2009-10-21, kaklis at gmail.com wrote:
> 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:
> <?xml version="1.0" encoding="UTF-8"?>
> <DecisionTree type="DescisionTree">
...
> </DecisionTree>
>
> Is there a way to do it?

No. Impossible.

No, of course it is possible.  I'd think of it as a problem of (a)
making clear to yourself what the input format (language) is, (b)
write a parser for it (which transform it to Python data structures
and (c) write code to dump the data structures according to some DTD
(or whatever the XML people call it these days).

(c) seems to be the easy part.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list