def xml_attr_or_element(xml_node, name):
    """ Attempt to get the value of name from the xml_node. This could be an attribute or
        a child element.
    """
    attr_val = xml_node.get(name, None)
    if attr_val is not None:
        return attr_val.encode('utf-8').strip()
    for child in xml_node.getchildren():
        if child.tag == name:
            return child.text.encode('utf-8').strip()
    return None