0

XML を解析しようとしていますが、応答からリンクを抽出しようとすると問題が発生します。

私のXMLは次のようになります:

<properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" lastUpdate="2016-11-23">
    <property myId="3" lastUpdate="2016-11-20T01:25:17+01:00" xlink:href="http://example.com/webservice/rest/1/properties/3"/>
    <property myId="10" lastUpdate="2016-11-16T03:52:54+01:00" xlink:href="http://example.com/webservice/rest/1/properties/10"/>
    ...

そして私の機能:

    r = requests.get(url, auth=(self.usr, self.psw))
    xml = r.content
    root = ET.fromstring(xml)
    for prop in root:
        m_id= prop.attrib['myId']
        my_url = prop.attrib['xlink:href']

id属性を抽出できますが、URL を取得しようとするとエラーが発生します

4

0 に答える 0