我有一个XML文件,其代码如下:
<spotter num="0187" report_at="2014-03-15 20:10:25" lat="49.8696518" lng="-80.0973129"callsign="wxman132" active="1" public="" gps="0" phone="" email="addu@nnu.nne" first="" last=""></spotter>
我试过用多米尼多姆,但如何从XML文件中轻松地解析出lat和lng变量值呢?在
提前感谢您的帮助!在
Tags:
您需要使用XML解析器,如ElementTree、BeautifulSoup或{a3}。在
下面是一个使用标准库中的
ElementTree
的示例:下面是一个使用
^{pr2}$BeautifulSoup
的示例:两种印刷品:
就格式良好的xml结构而言,
BeautifulSoup
更为宽容(请参见,我不得不编辑xml以使ElementTree
正常工作),而且它实际上更容易使用。在希望有帮助。在
Pyparsing有一个从HTML标记中提取属性的内置方法,而不必为整个页面构建完整的对象模型。在
印刷品
^{pr2}$相关问题 更多 >
编程相关推荐