使用lxml python库从xml文件中获取完整元素

时间:2018-04-23 07:35:05

标签: python xml lxml

我正在使用下面的代码从xml文件中完全过滤掉一个元素(包含所有子元素),我将其解析为ET。但是在输出中我什么也没收到,你能不能帮我拿到我的数据:

代码:

from lxml import etree
parsedXML = etree.parse("data_xml.xml")
parsedXML=StringIO(parsedXML)
a=parsedXML.xpath('//measInfo[@measInfoId="67109488"]')

data_xml:

<measCollecFile>
 <measData>   
   <measInfo measInfoId="67109488">
                <granPeriod duration="PT3600S" endTime="2018-04-21T01:00:00+04:30"/>
                <repPeriod duration="PT3600S"/>
                <measTypes>67194363 67194364 67194365 67194368 67194369 67194370 67194371 67194372 67194373 67194374 67204393 67204394 67204395 67204396 67204764 67204765 73441531 73441532 </measTypes>
                <measValue measObjLdn="BLRNCH03/FEGE:PN=3, SN=25, SRN=1">
                    <measResults>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 </measResults>
                </measValue>
                <measValue measObjLdn="BLRNCH03/FEGE:PN=2, SN=25, SRN=1">
                    <measResults>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 </measResults>
                </measValue>
                <measValue measObjLdn="BLRNCH03/FEGE:PN=1, SN=25, SRN=1">
                    <measResults>0 0 0 0 61043.406 35116.8 45024.105 301966.509 165096 223853.859 20260847268 100734236526 154174172 191309061 0 0 53039.886 238680.333 </measResults>
                </measValue>
                <measValue measObjLdn="BLRNCH03/FEGE:PN=0, SN=25, SRN=1">
                    <measResults>0 0 0 0 71847.747 37518.4 50369.693 303467.379 164086.4 221952.38 22666361970 99878571071 162303835 193826669 0 0 64721.428 235521.769 </measResults>
                </measValue>
                <measValue measObjLdn="BLRNCH03/FEGE:PN=3, SN=24, SRN=1">
                    <measResults>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 </measResults>
    </measInfo>
 </measData>
</measCollecFile>

0 个答案:

没有答案