相关疑难解决方法(0)

使用ElementTree将xml转换为字典

我正在寻找使用ElementTree的XML到字典解析器,我已经找到了一些,但它们排除了属性,在我的情况下,我有很多属性.

python xml dictionary elementtree

28
推荐指数
3
解决办法
4万
查看次数

遍历 XML?

使用 python 浏览 XML 的最简单方法是什么?

<html>
 <body>
  <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:body>
    <getservicebyidresponse xmlns="http://www.something.com/soa/2.0/SRIManagement">
     <code xmlns="">
      0
     </code>
     <client xmlns="">
      <action xsi:nil="true">
      </action>
      <actionmode xsi:nil="true">
      </actionmode>
      <clientid>
       405965216
      </clientid>
      <firstname xsi:nil="true">
      </firstname>
      <id xsi:nil="true">
      </id>
      <lastname>
       Last Name
      </lastname>
      <role xsi:nil="true">
      </role>
      <state xsi:nil="true">
      </state>
     </client>
    </getservicebyidresponse>
   </soapenv:body>
  </soapenv:envelope>
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我会使用正则表达式并尝试获取我需要的行的值,但是有没有 Pythonic 的方法?诸如此类的东西xml[0][1]

python xml python-2.6

2
推荐指数
1
解决办法
5017
查看次数

标签 统计

python ×2

xml ×2

dictionary ×1

elementtree ×1

python-2.6 ×1