En Mon, 24 Sep 2007 22:53:57 -0300, Robert Dailey <[EMAIL PROTECTED]>  
escribi�:
> Any easier way to do a 'replace' then using start(), end(), and slicing
> operations? I'm currently doing it manually.

Yes: forget about regular expressions. ElementTree does that for free:

source = """
<xml>
<root></root>
<root/>
<root><frame type="image"><action></action></frame></root>
<root><frame type="image"><action/></frame></root>
</xml>
"""

import xml.etree.ElementTree as ET
tree = ET.XML(source)
print ET.tostring(tree)

output:

<xml>
<root />
<root />
<root><frame type="image"><action /></frame></root>
<root><frame type="image"><action /></frame></root>
</xml>

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to