0

我想从此链接获取根节点的所有属性: http ://www.sec.gov/Archives/edgar/data/75829/000144530512003029/pll-20120731.xml

Main_Page = urllib2.urlopen("http://www.sec.gov/Archives/edgar/data/75829/000144530512003029/pll-20120731.xml")
                tree = ET.parse(Main_Page)
                root = tree.getroot()
List=root.attrib

但是 List 向我展示了 0 Length Array。那么我怎样才能获得属性值。而且它没有任何属性键。

4

1 回答 1

0

请参阅ElementTree:使用命名空间和限定名称

import urllib2
from xml.etree import ElementTree as ET

Main_Page = urllib2.urlopen("http://www.sec.gov/Archives/edgar/data/75829/000144530512003029/pll-20120731.xml")
for event, (name, value) in ET.iterparse(Main_Page, ['start-ns']):
    print name, ':', value

印刷

country : http://xbrl.sec.gov/country/2011-01-31
dei : http://xbrl.sec.gov/dei/2011-01-31
iso4217 : http://www.xbrl.org/2003/iso4217
link : http://www.xbrl.org/2003/linkbase
pll : http://www.pall.com/20120731
us-gaap : http://fasb.org/us-gaap/2011-01-31
utreg : http://www.xbrl.org/2009/utr
xbrldi : http://xbrl.org/2006/xbrldi
xbrli : http://www.xbrl.org/2003/instance
xlink : http://www.w3.org/1999/xlink
于 2013-07-20T16:14:43.000 回答