Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33587

Re: xml data or other?

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: xml data or other?
Date 2012-11-20 06:48 +0100
References <mailman.3490.1352465695.27098.python-list@python.org> <96b24715-cb4b-4588-844e-fc2e2f51a170@m4g2000pbd.googlegroups.com> <50A8E36A.5010606@gmail.com> <5B80DD153D7D744689F57F4FB69AF474167B8C1C@SCACMX008.exchad.jpmchase.net>
Newsgroups comp.lang.python
Message-ID <mailman.30.1353390518.29569.python-list@python.org> (permalink)

Show all headers | View raw


Prasad, Ramit, 19.11.2012 22:42:
> Artie Ziff wrote:
>> Writing XML files so to see whats happening. My plan is to
>> keep xml data in memory and parse with xml.etree.ElementTree.
>>
>> 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 think your description text should be in a CDATA section.
> http://en.wikipedia.org/wiki/CDATA#CDATA_sections_in_XML

Ah, don't bother with CDATA. Just make sure the data gets properly escaped,
any XML serialiser will do that for you. Just generate the XML using
ElementTree and you'll be fine. Generating XML as literal text is not a
good idea.

Stefan

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

xml data or other? Artie Ziff <artie.ziff@gmail.com> - 2012-11-09 04:54 -0800
  Re: xml data or other? rusi <rustompmody@gmail.com> - 2012-11-09 05:50 -0800
    Re: xml data or other? Artie Ziff <artie.ziff@gmail.com> - 2012-11-18 05:32 -0800
      Re: xml data or other? rusi <rustompmody@gmail.com> - 2012-11-18 07:54 -0800
        Re: xml data or other? rusi <rustompmody@gmail.com> - 2012-11-18 07:58 -0800
    RE: xml data or other? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-19 21:42 +0000
    Re: xml data or other? Stefan Behnel <stefan_ml@behnel.de> - 2012-11-20 06:48 +0100
  Re: xml data or other? shivers.paul@yahoo.co.uk - 2012-11-13 06:05 -0800
  Re: xml data or other? shivers.paul@yahoo.co.uk - 2012-11-13 06:05 -0800

csiph-web