0

I have a problem with parsing a XML with xmltodict. This method works on other XML-files online, but now I'm getting this error: "xml.parsers.expat.ExpatError: not well-formed (invalid token):"

What is going wrong here, and how can I fix/work around it?

import requests
import xmltodict

metadataxml = "https://nedlasting.geonorge.no/geonorge/Tjenestefeed_daglig.xml"

md_response = requests.get(metadataxml, stream=True)
md_data = md_response.text

xml = xmltodict.parse(md_data)

Johs
  • 73
  • 1
  • 7

1 Answers1

0

Changing response.text to response.content seemed to solve the issue.

metadataxml = "https://nedlasting.geonorge.no/geonorge/Tjenestefeed_daglig.xml"

md_response = requests.get(metadataxml, stream=True)
md_data = md_response.text

xml = xmltodict.parse(md_data)
Johs
  • 73
  • 1
  • 7