def _open_to_close_tag(tag):
    """
    Given an opening xml tag, return the matching close tag
    eg. '<YAMAHA_AV cmd="PUT"> becomes </YAMAHA_AV>
    """
    index = tag.find(' ')
    if index == -1:
        index = len(tag) - 1
    return '</' + tag[1:index] + '>'