def substitute(request, node, subs):
    """
    Look through the given node's children for strings, and
    attempt to do string substitution with the given parameter.
    """
    for child in node.childNodes:
        if hasattr(child, 'nodeValue') and child.nodeValue:
            child.replaceData(0, len(child.nodeValue), child.nodeValue % subs)
        substitute(request, child, subs)

    Look through the given node's children for strings, and
    attempt to do string substitution with the given parameter.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/domhelpers.py