如何在以下 XML 中检索类型的值
<info><category>Flip</category><info>2</info><type>Tree</type></info>
如何在以下 XML 中检索类型的值
<info><category>Flip</category><info>2</info><type>Tree</type></info>
使用元素树:
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)