or PI nodes. For element and attribute nodes, removes all children and replaces them by parsing content which is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Unfortunately, there isn't an API to pass raw content directly. An inefficient work-around is to escape the content with xmlEncodeSpecialChars before passing it. A better trick is clearing the old content with xmlNodeSetContent(node, None) first and then calling xmlNodeAddContent(node, content) . Unlike this function, xmlNodeAddContent accepts raw text. )