在python中访问xml中的子节点

在python中访问xml中的子节点,python,xml,xml-parsing,Python,Xml,Xml Parsing,如何在下面的XML中检索类型的值 <info><category>Flip</category><info>2</info><type>Tree</type></info> Flip2Tree 使用ElementTree: import xml.etree.ElementTree as E e = E.parse("test.xml") print(e.find("type").text) 使用

如何在下面的XML中检索类型的值

 <info><category>Flip</category><info>2</info><type>Tree</type></info>
Flip2Tree
使用ElementTree:

import xml.etree.ElementTree as E
e = E.parse("test.xml")
print(e.find("type").text)
使用minidom:

import xml.dom.minidom
d = xml.dom.minidom.parse("test.xml")
print(d.getElementsByTagName("type")[0].firstChild.data)
使用:

from BeautifulSoup import BeautifulStoneSoup
soup = BeautifulStoneSoup(open("test.xml"))
print(soup.find("type").text)