I am trying to parse an xml which contains regexes like so:
<conditions>
<condition pattern_matches="regex string"/>
</conditions>
However, when regex contains an unsafe character, for instance (<=a).*b$
, ElementTree raises a ParseError saying that xml is not well formed at <
character, even though the character is inside quotes.
I can of use <
instead of <
and then once parsed replace all such characters, but that renders complex regexes very difficult to read and requires rewriting regexes which contain such character combinations so as not to create false-positives, and loading raw xml file and then swapping characters for their safe variations, just to swap them back immediately afterwards seems unneccessarily cpu intensive.
How should I approach this problem? Is this too complicated for ElementTree or am I doing something wrong?