<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_hypergraph(string):
 """ Read a graph from a XML document. Nodes and hyperedges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: hypergraph @return: Hypergraph """

    
    hgr = hypergraph()
    
    dom = parseString(string)
    for each_node in dom.getElementsByTagName("node"):
        hgr.add_node(each_node.getAttribute('id'))
    for each_node in dom.getElementsByTagName("hyperedge"):
        hgr.add_hyperedge(each_node.getAttribute('id'))
    dom = parseString(string)
    for each_node in dom.getElementsByTagName("node"):
        for each_edge in each_node.getElementsByTagName("link"):
            hgr.link(str(each_node.getAttribute('id')), str(each_edge.getAttribute('to')))
    return hgr