-def inner_xml(node):
- """ returns node's text and children as a string
-
- >>> print(inner_xml(etree.fromstring('<a>x<b>y</b>z</a>')))
- x<b>y</b>z
- """
-
- nt = node.text if node.text is not None else ''
- return ''.join(
- [nt] + [etree.tostring(child, encoding='unicode') for child in node]
- )
-
-
-def set_inner_xml(node, text):
- """ sets node's text and children from a string
-
- >>> e = etree.fromstring('<a>b<b>x</b>x</a>')
- >>> set_inner_xml(e, 'x<b>y</b>z')
- >>> print(etree.tostring(e, encoding='unicode'))
- <a>x<b>y</b>z</a>
- """
-
- p = etree.fromstring('<x>%s</x>' % text)
- node.text = p.text
- node[:] = p[:]
-
-