This convenience function handles the special logic used
to add text content to an ElementTree-style node. The problem is that if the node does not
have any children, the new text is appended to the node's
.text attribute, but if there are any
children, the new text must be appended to the .tail attribute of the last child. Refer to
Section 2, “How ElementTree represents XML” for a discussion of why
this is necessary.
Here is the general calling sequence to add some text
string to
an existing s:
node
addText(node,s)