如何访问内容'用feedparser封闭?
<content type="application/xml">
<m:properties xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<d:Ref_Key>3a496b6e</d:Ref_Key
</m:properties>
</content>
访问内容&#39;
的代码d = feedparser.parse("http://localhos/odata/standard.odata/Document_Order")
d.entries[0].content[0]
返回类似
的内容{'base': u'http://localhos/odata/standard.odata/Document_Order', 'type': u'application/xml', 'value': u'', 'language': None}
然后如何获得&#39; m:properties&#39;和&#39; d:Ref_Key&#39; ?
答案 0 :(得分:0)
似乎feedparser cant pars不是XML标签,建议使用xml.etree.ElementTree
import requests
import xml.etree.ElementTree
url = http://localhost/standard.odata/Document_Visit
req = requests.get(self.url, auth=(self.login, self.password))
root = etree.fromstring(req.text.encode('utf-8'))
entrys = root.findall('{http://www.w3.org/2005/Atom}entry')
properties = content.findall('{http://schemas.microsoft.com/ado/2007/08/dataservices/metadata}properties')
prop_dict = dict()
for prop in properties[0]:
pritn prop