[Fwd: Using cElementTree and elementtree.ElementInclude]

M

Mark

-------- Original Message --------
Subject: Using cElementTree and elementtree.ElementInclude
Date: Mon, 23 Oct 2006 09:40:24 -0500
From: Mark E. Smith <[email protected]>
Organization: AEDC
To: (e-mail address removed)
cElementTree cannot hold ElementTree instances.

can you post a small but self-contained example showing how you got this
error?



#from elementtree.ElementTree import ElementTree, dump # This works
from cElementTree import ElementTree, dump # This does not
from elementtree import ElementInclude

etree = ElementTree(file='xml_in.xml').getroot()
dump(etree)

ElementInclude.include(etree)
dump(etree)

for child in etree.find('./included_root').findall('./*'):
# Copy the child down to the root
etree.append(child)
# Remove the root/included_root
etree.remove(etree.find('./included_root'))
dump(etree)


<!--xml_in.xml-->
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<child name="first"/>
<xi:include href="xml_included.xml"/>
</root>

<!--xml_included.xml-->
<included_root>
<child name="second"/>
<child name="third"/>
</included_root>


Thanks for the help.
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top