def is_valid(xml_string):
    """validates a unicode string containing xml"""
    xml_file = StringIO.StringIO(xml_string.encode('utf-8'))
    
    parser = XmlScanner()
    parser.setContentHandler(ContentHandler())
    try:
        parser.parse(xml_file)
    except SAXParseException:
        return False
    
    return True
def is_valid ( xml_string ) : xml_file = StringIO . StringIO ( xml_string . encode ( 'utf-8' ) ) parser = XmlScanner ( ) parser . setContentHandler ( ContentHandler ( ) ) try : parser . parse ( xml_file ) except SAXParseException : return False return True
validates a unicode string containing xml