Вопрос

I'm trying to parse the content.xml inside a ODF-file. I've read the file into a string and i've got a tree object with lxml.etree:

tree = etree.XML(string)

But now I need to find every subelement that is text:a OR text:h. I've been told in previous question that I could use XPath. I've tried but got stuck every single time. Can't even find one of those elements.

If i try:

elem = tree.xpath('//text:p')
I just get a
XPathEvalError: Undefined namespace prefix

So how do I get a list with BOTH of thoose subelements in the right order so i can iterate over them?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top