Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.06; 'subject:xml': 0.07; 'python': 0.08; 'subject:characters': 0.09; 'am,': 0.13; 'subject:file': 0.13; 'wrote:': 0.15; 'library': 0.15; 'disk.': 0.16; 'received:mindspring.com': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; 'insert': 0.19; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; 'literal': 0.23; 'cheers': 0.23; 'xml': 0.25; 'string': 0.26; 'developing': 0.27; 'problem': 0.29; 'subject:?': 0.31; 'this.': 0.31; 'references': 0.32; 'file.': 0.32; 'to:addr:python-list': 0.34; 'received:24': 0.34; 'etc.)': 0.34; 'post': 0.34; 'all.': 0.35; 'question': 0.35; 'charset:us-ascii': 0.36; 'file': 0.36; 'anything': 0.37; 'some': 0.37; 'doing': 0.37; 'using': 0.37; 'subject:: ': 0.38; 'put': 0.38; 'header:Mime-Version:1': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'header :Message-Id:1': 0.61; 'organisation': 0.67; 'special': 0.67; 'received:69.73': 0.84 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: how to get Python to insert special characters in an xml file? From: Philip Semanchuk In-Reply-To: <4E202A22.7080207@gmail.com> Date: Fri, 15 Jul 2011 08:56:31 -0400 Content-Transfer-Encoding: quoted-printable References: <4E202A22.7080207@gmail.com> To: Lista-Comp-Lang-Python list X-Mailer: Apple Mail (2.1084) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - deimos.nocdirect.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - semanchuk.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310738714 news.xs4all.nl 23867 [2001:888:2000:d::a6]:47069 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9548 On Jul 15, 2011, at 7:53 AM, hackingKK wrote: > Hello all. > I am currently developing a python application which reads and writes = some data to an xml file. > I use the elementTree library for doing this. > My simple question is that if I have some thing like & as in "kk & = company " as organisation name, how can I have Python take this as a = litteral string including the & sign and put in the = tag? > Even same applies while reading the file. I would like to have the & = come as a part of the literal string. Hi Krishnakant, You don't need to do anything special to insert metacharacters like & = and < and > into XML using ElementTree. Just treat them as normal text = and ElementTree will change them to entity references (&, etc.) when = it writes your file to disk.=20 If you're having a specific problem with this, post some code. Cheers Philip=