I'd use xmltodict to make a python dictionary out of the XML data structure and pass this dictionary to the template inside the context:
import urllib2
import xmltodict
def homepage(request):
file = urllib2.urlopen('https://www.goodreads.com/review/list/20990068.xml?key=nGvCqaQ6tn9w4HNpW8kquw&v=2&shelf=toread')
data = file.read()
file.close()
data = xmltodict.parse(data)
return render_to_response('my_template.html', {'data': data})
Answer from alecxe on Stack OverflowPandas
pandas.pydata.org › docs › reference › api › pandas.read_xml.html
pandas.read_xml — pandas 3.0.1 documentation
Encoding of XML document. parser{{‘lxml’,’etree’}}, default ‘lxml’ · Parser module to use for retrieval of data. Only ‘lxml’ and ‘etree’ are supported. With ‘lxml’ more complex XPath searches and ability to use XSLT stylesheet are supported. ... A URL, file-like object, or a string path containing an XSLT script.
W3Schools
w3schools.com › xml › xml_parser.asp
XML Parser
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Building a URL that downloads an XML File
Do you have a web server? You just need to upload your xml file, link to the file, and it will be downloaded by whoever uses the link; no programming needed. More on reddit.com
Learing how to scrape/parse data from lists of urls. Need help
Hi I am learning Python and need to parse data from a website like headhunter. I have got the sitemap(https://hh.ru/sitemap/main.xml) from the site with a lot of urls, every url contains even more urls, which lead you to the website. My task is to only find urls which will lead me to pages ... More on discuss.python.org
Writing and then reading back an XML file
The code shown below does the following: 1-gets an XML from the internet-this works 2-save the data to a disk file -this works 3-reads back the data from disk -this does not work. There no errors, but the data is None instead of containing the XML data which is about 93k in size. More on discuss.python.org
reading xml with python3
The xml is gzip compressed - requests handles this automatically for you which you could use instead of urllib.
response = requests.get(url)
tree = etree.fromstring(response.content)
http://stackoverflow.com/a/26435241 discusses solutions for doing it with urllib
More on reddit.comVideos
07:05
Extract URLs from sitemap xml in Python - YouTube
28:25
Parsing XML with Python (DevNet) - YouTube
08:30
Python Web Programming - Parsing Xml - YouTube
38:58
Python XML Parsing Tutorial Read And Write XML Files In Python ...
Parse XML Files with Python - Basics in 10 Minutes
Top answer 1 of 3
49
I'd use xmltodict to make a python dictionary out of the XML data structure and pass this dictionary to the template inside the context:
import urllib2
import xmltodict
def homepage(request):
file = urllib2.urlopen('https://www.goodreads.com/review/list/20990068.xml?key=nGvCqaQ6tn9w4HNpW8kquw&v=2&shelf=toread')
data = file.read()
file.close()
data = xmltodict.parse(data)
return render_to_response('my_template.html', {'data': data})
2 of 3
13
xmltodict using requests
import requests
import xmltodict
url = "https://yoursite/your.xml"
response = requests.get(url)
data = xmltodict.parse(response.content)
GitHub
gist.github.com › MichelleDalalJian › f587530b6e0a72357541f39b2022aa55
Extracting Data from XML: The program will prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the file. · GitHub
url = "http://py4e-data.dr-chuck.net/comments_1659064.xml" serviceurl = urllib.request.Request(url) uh = urllib.request.urlopen(url, context=ctx) data = uh.read() #print('Retrieved', len(data), 'characters') #print(data.decode()) tree = ET.fromstring(data) lst = tree.findall('comments/comment') #print('User count:', len(lst)) for item in lst: #print('Numero:', item.find('count').text) sum = sum + int(item.find('count').text) print("Total:",sum)
Python
docs.python.org › 3 › library › xml.etree.elementtree.html
xml.etree.ElementTree — The ElementTree XML API
January 29, 2026 - Its input-side API is similar to that of XMLParser, but instead of pushing calls to a callback target, XMLPullParser collects an internal list of parsing events and lets the user read from it. events is a sequence of events to report back. The supported events are the strings "start", "end", "comment", "pi", "start-ns" and "end-ns" (the “ns” events are used to get detailed namespace information).
Reddit
reddit.com › r/learnpython › building a url that downloads an xml file
r/learnpython on Reddit: Building a URL that downloads an XML File
September 27, 2022 -
Hi!
I'm trying to figure out how to set up a URL that when hit downloads an XML file. I think I would use something like Flask to set this up, but am not quite sure if that's correct
Would love some help figuring out exactly how I can set this up. Thanks!
EncodedNA
encodedna.com › python › how-to-fetch-data-from-an-xml-file-using-url-in-python.htm
How to fetch data from an XML file using URL in Python
The "requests.get()" method in Python, is used to send a GET request. The request is made using a URL. The URL is for the XML file, which is stored in a remote server. Similar JavaScript example: How to get XML data from remote file using JavaScript async and await?
Pybites
pybit.es › articles › download-xml-file
How To Download An XML File With Python - Pybites
June 30, 2021 - Every time you run that script with your requests.get code in place, you’re making a call to the target web server. This generates unnecessary traffic and load on that server which is a pretty crappy thing to do! The nicer and Pythonic thing to do is to have a separate script that does the request once and saves the required data to a local file. Your primary scraping or analysis script then references the local file. ... import requests URL = "http://insert.your/feed/here.xml" response = requests.get(URL) with open('feed.xml', 'wb') as file: file.write(response.content)
DEV Community
dev.to › nicfoxds › how-to-get-data-from-an-api-process-xml-in-python-4c1
How to Get Data from an API & Process XML in Python - DEV Community
July 5, 2020 - import requests # for using API import xml.etree.ElementTree as ET # for parsing XML import numpy as np # for using pandas import pandas as pd # for using dataframes · Then save your api key as a variable. I've called mine api_key: ... Copy-paste the request URL that was created by the 'Try it!' feature on the Zoopla API website and save it as a variable called request_url:
YouTube
youtube.com › codepoint
python download xml from url - YouTube
Download this code from https://codegive.com Certainly! Downloading XML from a URL in Python can be done using the requests library for making HTTP requests ...
Published February 6, 2024 Views 27
Real Python
realpython.com › python-xml-parser
A Roadmap to XML Parsers in Python – Real Python
September 25, 2023 - While it hasn’t been updated in a few years, the untangle library might soon become your favorite way of parsing XML in Python. There’s only one function to remember, and it accepts a URL, a filename, a file object, or an XML string: ... >>> import untangle >>> # Parse XML from a URL >>> untangle.parse("http://localhost:8000/smiley.svg") Element(name = None, attributes = None, cdata = ) >>> # Parse XML from a filename >>> untangle.parse("smiley.svg") Element(name = None, attributes = None, cdata = ) >>> # Parse XML from a file object >>> with open("smiley.svg") as file: ...
PACER
pacer.uscourts.gov › file-case › developer-resources
Developer Resources | PACER: Federal Court Records
The XML Case Opening module allows more data to be captured through an uploaded XML file and streamlines the data entry process for attorneys.
TechTrek
techtrek.io › how-to-parse-xml-data-with-python-from-url
How to Parse XML Data with Python From URL
March 5, 2020 - Looking at the XML URL from our example, I am interested in grabbing the number of owners of this game. I used ctrl-f and searched for “own” to find the following line: Here, you can see the tag is · I’m only interested in the value (80966). It doesn’t matter that this tag is nested within ranks (which is itself nested within ratings which is nested within statistics). To grab this value, we’ll use the Python lines: owned = dom.getElementsByTagName...
Python.org
discuss.python.org › python help
Writing and then reading back an XML file - Python Help - Discussions on Python.org
May 13, 2023 - The code shown below does the following: 1-gets an XML from the internet-this works 2-save the data to a disk file -this works 3-reads back the data from disk -this does not work. There no errors, but the data i…