- 论坛徽章:
- 1
|
你好,还有个问题想问下,我要用的xml的文件有很多层,比如
我想读出Aera的值
import xml.etree.ElementTree as ET
with open('jiyi.xml') as fp:
jiyi_as_string=fp.read()
tree = ET.parse('jiyi.xml')
root = tree.getroot()
root = ET.fromstring(jiyi_as_string)
x1=root.find('./Vsp_Geometry/Component_List[1]/Component/Section_List/Section/Area').text
print x1
这是我写的程序
但是出现了
Traceback (most recent call last):
File "F:\python练习\jiexi", line 4, in <module>
tree = ET.parse('jiyi.xml')
File "H:\Python27\lib\xml\etree\ElementTree.py", line 1182, in parse
tree.parse(source, parser)
File "H:\Python27\lib\xml\etree\ElementTree.py", line 656, in parse
parser.feed(data)
File "H:\Python27\lib\xml\etree\ElementTree.py", line 1642, in feed
self._raiseerror(v)
File "H:\Python27\lib\xml\etree\ElementTree.py", line 1506, in _raiseerror
raise err
ParseError: mismatched tag: line 243, column 39
这样的错误,不知道怎么修改。。
回复 2# timespace |
|