def chunk_to_string(chunk): # XXX изменится, при смене библиотеки! if isinstance(chunk, et._Element): yield et.tostring(chunk) elif isinstance(chunk, Doc): for i in chunk._finalize_data(): yield i elif isinstance(chunk, list): for i in chunk: for x in chunk_to_string(i): yield x else: yield chunk
def _cb(xml, resp): xpath = xml.xpath("/doc/*") assert len(xpath) == 1 assert etree.tostring(xpath[0]) == CDATA_XML