我正在尝试使用python中的cElementTree库解析xml。但是当我尝试运行程序时,它给了我错误。
#!/usr/bin/python
import os
import xml.etree.ElementTree as etree
filename = "mood_ib_history_parameters_DEV.xml"
__currentlocation__ = os.getcwd()
__fullpath__ = os.path.join(__currentlocation__,filename)
tree = etree.parse(__fullpath__)
root = tree.getroot()
for child in root:
print child.tag
print child.attrib
mood_ib_history_parameters_DEV.xml
的内容:
<IB_Details>
<hive_db>installbase</hive_db>
<EDGE_HIVE_CONN>${EDGE_HIVE_CONN2}</EDGE_HIVE_CONN>
<target_dir>somepath</target_dir>
<to_email_alias>sr_ssot_dev@cisco.com</to_email_alias>
<to_email_cc>hi@someone</to_email_cc>
<from_email_alias>mail@google.com</from_email_alias>
<dburl>jdbc:</dburl>
<SQOOP_EDGE_CONN>${SQOOP_EDGE_NODE_1}</SQOOP_EDGE_CONN>
<user_name>U</user_name>
<password>P</password>
<IB_log_table>IB_log</IB_log_table>
<SR_DG_master_table>master</SR_DG_master_table>
<SR_DG_table>governance_log</SR_DG_table>
</IB_Details>