def append_minidom_xml_to_elementtree_xml(parent, xml, recursive=False, attributes=None):
<EOL>if recursive is False:<EOL><INDENT>tag_name = xml.documentElement.tagName<EOL>node = xml.getElementsByTagName(tag_name)[<NUM_LIT:0>]<EOL>new_elem = SubElement(parent, tag_name)<EOL>if attributes:<EOL><INDENT>for attribute in attributes:<EOL><INDENT>if xml.documentElement.getAttribute(attribute):<EOL><INDENT>new_elem.set(attribute, xml.documentElement.getAttribute(attribute))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>node = xml<EOL>tag_name = node.tagName<EOL>new_elem = parent<EOL><DEDENT>i = <NUM_LIT:0><EOL>for child_node in node.childNodes:<EOL><INDENT>if child_node.nodeName == '<STR_LIT>':<EOL><INDENT>if not new_elem.text and i <= <NUM_LIT:0>:<EOL><INDENT>new_elem.text = child_node.nodeValue<EOL><DEDENT>elif not new_elem.text and i > <NUM_LIT:0>:<EOL><INDENT>new_elem_sub.tail = child_node.nodeValue<EOL><DEDENT>else:<EOL><INDENT>new_elem_sub.tail = child_node.nodeValue<EOL><DEDENT><DEDENT>elif child_node.childNodes is not None:<EOL><INDENT>new_elem_sub = SubElement(new_elem, child_node.tagName)<EOL>new_elem_sub = append_minidom_xml_to_elementtree_xml(new_elem_sub, child_node,<EOL>True, attributes)<EOL><DEDENT>i = i + <NUM_LIT:1><EOL><DEDENT>return parent<EOL>
Recursively,
Given an ElementTree.Element as parent, and a minidom instance as xml,
append the tags and content from xml to parent
Used primarily for adding a snippet of XML with <italic> tags
attributes: a list of attribute names to copy