lmlx & & caracter

Stefan Behnel stefan_ml at behnel.de
Tue Oct 27 09:36:26 CET 2009


Toff, 27.10.2009 09:15:
> On 27 oct, 09:03, Christian Heimes <li... at cheimes.de> wrote:
>> Toff wrote:
>>> hello
>>> i can't parse a file with lxml
>>> ================================================================
>>>   <?xml version="1.0" encoding="iso-8859-1" ?>
>>>  <packages>
>>>  <package id="firefox" name="FireFox 3.5" >
>>>   <download url="http://download.mozilla.org/?
>>> product=firefox-3.5&os=win&lang=fr"  />
>>>   </package>
>>>   </packages>
>>> =========================================================================
>>> i know that & is a special caracter in xml
>> Because & has a special meaning in XML you have to quote a literal & as
>> &
> 
> but does my download url still allways works with & replace by $amp;

In case you want to know if the URL keeps working if you replace '&' by
'&' in your XML file, then the answer is that it will actually /start/
working that way, because it will not work the way you show above. An XML
parser will return the URL as expected.

Note that it's also best to use an XML toolkit to actually generate XML, in
case you wrote the above file programmatically.

Stefan



More information about the Python-list mailing list