我正在尝试用一组新的坐标替换 bbox 内的元素。
我的代码:
# import element tree
import xml.etree.ElementTree as ET
#import xml file
tree = ET.parse('C:/highway.xml')
root = tree.getroot()
#replace bounding box with new coordinates
elem = tree.findall('bbox')
elem.txt = '40.5,41.5,-12.0,-1.2'
我的 xml 文件:
<geoEtl>
<source>
<server>localhost</server>
<port>xxxx</port>
<db>vxxx</db>
<user>xxxx</user>
<passwd>xxxx</passwd>
</source>
<targetDir>/home/firstuser/</targetDir>
<bbox>-52.50,-1.9,52.45,-1.85</bbox>
<extractions>
<extraction>
<table>geo_db_roads</table>
<outputName>highways</outputName>
<filter>highway = 'motorway'</filter>
<geometry>way</geometry>
<fields>
<field>name</field>
</fields>
</extraction>
</extractions>
</geoEtl>
已经尝试了多种方法来做我在这里找到的事情,但它似乎不起作用。谢谢。
我收到的错误如下:
line 20, in <module> elem.txt = '40.5,41.5,-12.0,-1.2' AttributeError: 'list' object has no attribute 'txt' –