【发布时间】:2016-06-08 14:14:27
【问题描述】:
我有一个 XML 文件,我想根据字符串检索元素的 text 属性。
在下面的示例中,我想查找包含字符串 home 的所有主题元素(两个元素)。获得元素后,我可以检索 text 值。
<?xml version="1.0" ?>
<zAppointments reminder="15">
<appointment>
<subject>Bring pizza home</subject>
<shape>circule</shape>
</appointment>
<appointment>
<subject>Bring hamburger home</subject>
<shape>box</shape>
</appointment>
<appointment>
<subject>Bring banana homes</subject>
</appointment>
<appointment>
<subject>Check MS Office website for updates</subject>
</appointment>
</zAppointments>
【问题讨论】:
标签: python python-3.x lxml