Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Using cElementTree and elementtree.ElementInclude

Reply
Thread Tools

Using cElementTree and elementtree.ElementInclude

 
 
Mark E. Smith
Guest
Posts: n/a
 
      10-23-2006
> cElementTree cannot hold ElementTree instances.
>
> can you post a small but self-contained example showing how you got this
> error?


> </F>




#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 xmlnsi="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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When to clear elements using cElementTree Ben Temperton Python 1 10-19-2012 09:15 PM
Problem with cPickle and cElementTree Barry Python 1 10-10-2008 05:27 AM
Issues with XMLTreeBuilder in cElementTree and ElementTree Michael Becker Python 1 03-23-2008 04:51 PM
[Fwd: Using cElementTree and elementtree.ElementInclude] Mark Python 0 10-27-2006 01:45 PM
Using cElementTree and elementtree.ElementInclude Mark Python 0 10-20-2006 09:38 PM



Advertisments