Are you looking for something like this:
# ------------------------------
def remove(root, tag, text):
items = root.xpath(f'.//{tag}')
for item in items:
if item.text == text:
parent = item.getparent()
parent.remove(item)
return root
# ------------------------------
Also look at element.iter, element.iterdescendants, etc.
Dave
On Fri 30 Jul 2021 11:02:59 AM PDT, Gilles wrote:
Hello,
I'm only getting started with (l)xml, and was curious to know if
someone had an example of how to remove all items in an XML file
that match the following string:
^\t*<ele>100.25</ele>\r\n
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: dkuhl...@davekuhlman.org
--
Dave Kuhlman
http://www.davekuhlman.org
_______________________________________________
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