Tim Arnold wrote:

> I figure there must be a way to do it by creating a 'div' SubElement to the 
> 'body' tag and somehow copying the rest of the tree under that SubElement, 
> but it's beyond my comprehension.
> 
> How can I accomplish this?
> (I know I could put the class on the body tag itself, but that won't satisfy 
> the powers-that-be).

for completeness, here's an efficient and fairly straightforward way to 
do it under plain 2.5 xml.etree:

body = doc.find(".//body")

# clone and mutate the body element
div = copy.copy(body)
div.tag = "div"
div.set("class", "remapped")

# replace the body contents with the new div
body.clear()
body[:] = [div]

</F>

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

Reply via email to