擅长:python、mysql、java
<p>你的第一个问题是你想要的标签名是“menulist”。我使用<code>xml.dom.minidom</code>来解析它,只是作为一个基本示例来说明,因为我从未使用过PyDOM:</p>
<pre><code>>>> ecd = document.getElementsByTagName('menulist')
[<DOM Element: menulist at 0x1006e2710>]
>>> ecd[0].tagName
u'menulist'
>>> ecd[0].attributes.items()
[(u'name', u'mailencode'), (u'id', u'mailencode')]
</code></pre>
<p>然后单独拉出menulist标记,然后检查其子节点:</p>
<pre><code>>>> menulist = ecd[0]
>>> menulist.childNodes
[<DOM Text node "u'\n '">, <DOM Element: menupopup at 0x1006e29e0>, <DOM Text node "u'\n '">]
</code></pre>
<p>然后检查<code>menupop</code>标记的子节点:</p>
<pre><code>>>> menulist.childNodes[1]
<DOM Element: menupopup at 0x1006e29e0>
>>> menulist.childNodes[1].childNodes
[<DOM Text node "u'\n '">, <DOM Element: menuitem at 0x1006e2b90>, <DOM Text node "u'\n '">, <DOM Element: menuitem at 0x1006e2ef0>, <DOM Text node "u'\n '">]
</code></pre>
<p>可能有更好的方法,尤其是使用PyDOM的方法。我只是想说明你需要小心你要找的标签名。你知道吗</p>