Press "Enter" to skip to content

Python – How to Read XML from URL?

In Python, you can use urllib.request and xml.etree.ElementTree library to parse and read XML from URL. The following is an example:

Python Program Example – Read XML from URL

Below Python program will download and read the Oracle Database RSS feed through the URL. It will open the URL ( using the urlopen method of urllib.request library and then it will parse and read the XML data using parse method of library xml.etree.ElementTree.

from urllib.request import urlopen
from xml.etree.ElementTree import parse

var_url = urlopen('')
xmldoc = parse(var_url)

for item in xmldoc.iterfind('channel/item'):
    title = item.findtext('title')
    date = item.findtext('pubDate')
    link = item.findtext('link')



Webcast: Oracle Database 19c: Strategy, Features & New Customers – April 9
Mon, 01 Apr 2019 13:09:04 +0000

Win Over Financial Services Prospects with MySQL Enterprise Edition 
Thu, 28 Mar 2019 21:10:44 +0000

How will you design the future for Data & Analytics? - April 26, 2019
Thu, 21 Mar 2019 12:38:22 +0000

MySQL Enterprise Edition - High Availablity Campaign Now Available
Thu, 07 Mar 2019 23:00:00 +0000

Stay Ahead of the Game with Autonomous Database Training

See also:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community for developers and ask your question. It is FREE.

Vinish Kapoor


Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Inline Feedbacks
View all comments