def xml(self, str_source, str_encoding='', int_options=0): try: self.xmlDoc = libxml2.readerForDoc(str_source, None, str_encoding, int_options) return True except libxml2.treeError, e: print e return False
</foo>""" expect="""0 1 foo 0 1 14 #text 0 1 1 label 0 2 3 #text 0 1 15 label 0 1 14 #text 0 1 1 item 0 2 3 #text 0 1 15 item 0 1 14 #text 0 0 15 foo 0 """ result = "" reader = libxml2.readerForDoc(docstr, "test1", None, 0) ret = reader.Read() while ret == 1: processNode(reader) ret = reader.Read() if ret != 0: print("Error parsing the document test1") sys.exit(1) if result != expect: print("Unexpected result for test1") print(result) sys.exit(1) #