0

I'm trying to parse an XML but I've got problems when trying to extract a link from the response.

My XML looks like:

<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"/>
    ...

And my function:

    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']

I can extract the id attribute, but I get an error when tries to get the URL

Pablo Pardo
  • 729
  • 5
  • 12
  • 26
  • "It crashes"? As in, your screen goes black and your computer restarts? – Tomalak Nov 23 '16 at 12:13
  • Seriously though: I am fairly sure the duplicate thread answers your question, because it covers the one thing you code is missing. If that's not the case, please be more specific about what the issue is and I will re-open the question. – Tomalak Nov 23 '16 at 12:16

0 Answers0