import xml.etree.ElementTree as ET
import os
import requests
from requests.auth import HTTPBasicAuth
def iterate_xml_automate(link):
#Parent page parsing
all_href = []
all_href.append(link)
tree = ET.fromstring(requests.get(link,
auth= HTTPBasicAuth('login', 'Password')).text.encode('utf-8')) # Parser object
#accessing href component from the XML tree
href = [link.attrib['href'] for link in tree.iter('link')]
all_href.append(href)
#Run the while loop till you find a href element in the successive xml file
while (len(href)!= 0):
tree_1 = ET.fromstring(requests.get(str(href[0]),
auth=HTTPBasicAuth('login', 'Password')).text.encode('utf-8'))
#Update href for accessing next xml link
href = [link.attrib['href'] for link in tree_1.iter('link')]
all_href.appned(href)
#Returns all the href from subsequent pages
return href