Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'does.': 0.07; 'snippet': 0.07; 'subject:xml': 0.07; 'naturally': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:characters': 0.09; 'text?': 0.09; 'output': 0.11; '"&"': 0.16; 'expected.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'subject: \n ': 0.16; 'subject:handling': 0.16; 'turner': 0.16; 'subject:use': 0.16; 'insert': 0.19; 'header:In-Reply-To:1': 0.22; 'assume': 0.23; 'missed': 0.24; 'code': 0.24; 'xml': 0.25; 'do,': 0.28; 'stefan': 0.29; 'problem': 0.29; 'example': 0.30; 'subject:?': 0.31; "won't": 0.32; 'shows': 0.32; 'list': 0.32; 'brian': 0.33; 'it.': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'characters': 0.34; 'safely': 0.35; 'then.': 0.35; 'probably': 0.35; 'question': 0.35; 'subject:text': 0.35; 'file': 0.36; 'data.': 0.36; 'some': 0.37; 'but': 0.37; 'could': 0.37; 'received:org': 0.38; 'subject:can': 0.38; 'subject:: ': 0.38; 'put': 0.38; 'header:Mime-Version:1': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'did': 0.40; 'your': 0.60; 'waiting': 0.62; 'back': 0.63; 'show': 0.67; 'special': 0.67; 'subject:tree': 0.84; 'received:93': 0.86 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: can I use element tree for handling special characters in xml text? Date: Wed, 27 Jul 2011 13:42:47 +0200 References: <4E2FF38F.4040909@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: ppp-93-104-28-119.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11 In-Reply-To: <4E2FF38F.4040909@gmail.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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311766993 news.xs4all.nl 23895 [2001:888:2000:d::a6]:52843 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10382 hackingKK, 27.07.2011 13:16: > I have been waiting a lot to ask this question and I did ask some days back > but probably could not put it the proper way. I assume you missed the answer you got? > I want to know how I can safely include special characters like & or > in > xml text? > For example I store a small xml file containing list of organisations. > Many names have an "&" in the name as in brian & turner. > so the xml noad will be brian & turner > But I know this won't work directly. Yes it does. There's nothing you have to do, just put in the text and ElementTree will handle it. > my code naturally fails when I try to insert such data. You may want to show us your code then. Please provide a code snippet that shows the problem and present the output you get as well as the output you expected. Stefan