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 (https://blogs.oracle.com/oraclepartners/database-7/rss) 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('https://blogs.oracle.com/oraclepartners/database-7/rss')
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:

Written by Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.org and orclqa.com a question and answer forum for developers. You can connect with me on Facebook and Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *