如何使用python将xml属性解析为表?

时间:2015-09-23 16:02:38

标签: python xml parsing

您好我试图将一些xml数据解析成表。我可以使用dom解析器轻松获取xml元素,但我想知道访问属性的最佳方法,然后将它们放在像表格这样的数据结构中。

<Module name="Filter_Module1">
    <register name="Control/Status_reg" offset="64">
        <field name="" offset="63" power_upval="0" access="R" isreset="cleared to 0">
            <description> Error:Received two Footer Packets with no corresponding Header or Data Packets.</description> 
        <field>

        <field name="" offset="62" power_upval="0" access="R" isreset="cleared to 0">
            <description> Received no footer packet after a data packet.  Can only be cleared by a reset</description> 
        <field>

        <field name="" offset="61" power_upval="0" access="R" isreset="cleared to 0">
            <description> Received no data packets between a header and a footer packet.  Can only be cleared by a reset.</description> 
        <field>

        <field name="" offset="60" power_upval="0" access="R" isreset="cleared to 0">
            <description> Error:Received two Footer Packets with no corresponding Header or Data Packets.</description> 
        <field>

    </register>
</Module>

<Module name="SRAM"></Module>

1 个答案:

答案 0 :(得分:0)

使用XPATHlxml库为解析xml和执行XPATH查询提供支持