encontrando elementos por atributo con lxml
Necesito analizar un archivo xml para extraer algunos datos. Solo necesito algunos elementos con ciertos atributos, aquí hay un ejemplo de documento:
<root>
<articles>
<article type="news">
<content>some text</content>
</article>
<article type="info">
<content>some text</content>
</article>
<article type="news">
<content>some text</content>
</article>
</articles>
</root>
Aquí me gustaría obtener solo el artículo con el tipo "noticias". ¿Cuál es la forma más eficiente y elegante de hacerlo con lxml?
Intenté con el método find pero no es muy bueno:
from lxml import etree
f = etree.parse("myfile")
root = f.getroot()
articles = root.getchildren()[0]
article_list = articles.findall('article')
for article in article_list:
if "type" in article.keys():
if article.attrib['type'] == 'news':
content = article.find('content')
content = content.text