parsing multiple root element XML into text

Marko Rauhamaa marko at pacujo.net
Fri May 9 14:04:24 EDT 2014


Alain Ketterlin <alain at dpt-info.u-strasbg.fr>:

> How do you specify the encoding of sexprs? How can you require that an
> attribute value must match the value of an id-attribute? or whatever
> insanely complex integrity rule that XML Schemas lets you express? And
> so on.

I don't suppose there is a universal schema language available for S
expressions, nor do I suppose many people want such a thing. You specify
S expression encoding the way you specify Python library functions.

I think the worst part of XML is that you can't parse it without a DTD
or schema.

> If all you need to do is parse properly bracketed input, go with
> sexprs, or json, or yaml, or pickle if both ends are python programs.

I was very hopeful about json until I discovered they require the parser
to dynamically support five different character encodings.

XML at least standardized on UTF-8.

I have found ast.literal_eval() to be highly usable.

Pickle I would advise you to stay away from: <URL:
http://lwn.net/Articles/595352/>.


Marko



More information about the Python-list mailing list