def to_string(nodes):
    """
    Serialise a forest of DOM nodes to text,
    using the data fields of text nodes.
    :param nodes: the forest of DOM nodes
    :return: a concatenation of string representations.
    """
    result = []
    for node in nodes:
        if node.nodeType == node.TEXT_NODE:
            result.append(node.data)
        else:
            result.append(to_string(node.childNodes))
    return ''.join(result)