Hello, I'm still learning about lxml, and was wondering if there's a way to get the tree from the root to avoid writing the file to disk before re-reading it just for that:
============ INPUTFILE = "input.kml" #get rid of NS with open(INPUTFILE) as reader: content = reader.read() content= re.sub('<kml.*?>', '<kml>', content,0, re.DOTALL) #Read from memory to avoid writing cleaned file to disk and re-read parser = et.XMLParser(remove_blank_text=True) root = et.fromstring(bytes(content, encoding='utf8'), parser) #NameError: name 'tree' is not defined r = tree.xpath('/Document/name') print(r[0].tag) ============ Thank you. _______________________________________________ lxml - The Python XML Toolkit mailing list -- lxml@python.org To unsubscribe send an email to lxml-le...@python.org https://mail.python.org/mailman3/lists/lxml.python.org/ Member address: arch...@mail-archive.com