xml data or other?

rusi rustompmody at gmail.com
Sun Nov 18 10:54:05 EST 2012


On Nov 18, 6:32 pm, Artie Ziff <artie.z... at gmail.com> wrote:
> Unfortunately, xml parsing fails due to angle brackets inside
> description tags. In particular, xml.etree.ElementTree.parse()
> aborts on '<' inside xml data such as the following:
>
> <testname name="cron_test.sh">
>      <description>
>          This testcase tests if crontab <filename> installs the cronjob
>          and cron schedules the job correctly.
>      <\description>
>
> ##
>
> What is right way to handle the extra angle brackets?
> Substitute on line-by-line basis, if that works?
> Or learn to write a simple stack-style parser, or
> recursive descent, it may be called?
>
> I am open to comments to improve my code more to be more readable,
> pythonic, or better.
>
> Many thanks
> AZ

Start with cgi.escape perhaps?
http://docs.python.org/2/library/cgi.html



More information about the Python-list mailing list