This function returns the concatenation of all direct text children of a given node. The result will be an empty string if there are no text children. If there are any child nodes with text, their text will not be included.
Because of the strange way lxml handles
text, we'll use an XPath expression to do the work.
# - - - t e x t C o n t e n t
def textContent ( node ):
"""Return a node's text content.
[ node is an et.Element ->
return the concatenation of all direct text children of
node ]
"""
return "".join ( node.xpath ( 'text()' ) )