如何在使用python解析xml文件后获取属性值?
我有一个xml文件,当我使用下面的python代码解析它时。这是它打印的结果:如何在使用python解析xml文件后获取属性值?,python,python-3.x,xml,Python,Python 3.x,Xml,我有一个xml文件,当我使用下面的python代码解析它时。这是它打印的结果: columnInfo {'class': 'com.manu.webservices.metadata.ColumnBean', 'columnName': 'Employee', 'schemaName': 'Workers', 'tableName': 'humanResource'} 我想从tableName打印人力资源 Result Expected: humanResource 我尝试的是: impor
columnInfo {'class': 'com.manu.webservices.metadata.ColumnBean', 'columnName': 'Employee', 'schemaName': 'Workers', 'tableName': 'humanResource'}
我想从tableName打印人力资源
Result Expected:
humanResource
我尝试的是:
import xml.etree.ElementTree as ET
tree = ET.parse('file.xml')
root = tree.getroot()
for child in root:
print (child.tag, child.attrib)
child.attrib['tableName']
为什么这个问题被标记为“regex”?