1. 获取dom对象
import xml.dom.minidom
xml_dom = xml.dom.minidom.parse(xml_file)
2. 通过tag名称返回元素
for ele in xml_dom.getElementsByTagName("cim:PowerSystemResource.PSRType"):
pass
3. 获取元素的属性值、tag名称、元素文本、子节点、父节点
id = ele.parentNode.getAttribute("rdf:ID")
ele.nodeName()
name = ele.parentNode.getElementsByTagName("cim:Naming.name")[0].childNodes[0].data
ele.childNodes()
ele.parentNode