"Roland Koebler" wrote in message news:20160826140213.GA17438@localhost...
Hi,
OMG!
So, you have a fileformat, which looks like XML, but actually isn't XML,
and will break if used with some "real" XML.
I don't want to pursue this too much further, but I would like to point out
that my format is genuine XML. I can back that up with two pieces of
supporting evidence -
1. After going through the unescape > gui > edit > back_to_application >
escape routine, I validate the result before saving it -
try:
return etree.fromstring(value, parser=self.parser)
except (etree.XMLSyntaxError, ValueError) as e:
raise AibError(head=self.col_defn.short_descr,
body='Xml error - {}'.format(e.args[0]))
2. This is how I process the result at run-time. I do not try to parse it
myself. I convert it into an EtreeElement, and step through it. Each 'tag'
in the XML maps to a function name in the processing module -
for xml in elem:
await globals()[xml.tag](caller, xml)
The built-in ElementTree would work for this, but I actually use lxml,
because I use a little bit of xpath in my processing, which ElementTree does
not support.
Frank
--
https://mail.python.org/mailman/listinfo/python-list