有如下的XML:
<?xml version="1.0" encoding="utf-8"?>
<root>
<host></host>
<port>5050</port>
</root>
则得到port值的方法如下:
from xml.dom.minidom import parse
dom = parse("nsshd.xml")
root = dom.documentElement
portNode = root.getElementsByTagName("port")[0]
port = portNode.childNodes[0].data