In [1]:
from lxml import etree
In [6]:
with open('mycourses.xml') as f:
    t = etree.fromstring( f.read() )
In [7]:
t
Out[7]:
<Element mycourses at 0x7f7178056308>
In [11]:
for item in t:
    print( item )
    print('\t',item.tag)
    print('\t',item.attrib)
<Element course at 0x7f717806f688>
	 course
	 {'number': '448', 'name': 'Data-Oriented Computing for Mathematicians'}
<Element course at 0x7f717800c808>
	 course
	 {'number': '309', 'name': 'Linear Algebra'}
In [9]:
t.attrib
Out[9]:
{'school': 'UB'}
In [15]:
for item in t:
    print( item )
    print('\t',item.tag)
    print('\t',item.attrib)
    for subitem in item:
        print('\t',subitem )
        print('\t\t',subitem.tag)
        print('\t\t',subitem.attrib)
        print('\t\t',subitem.text)
<Element course at 0x7f7179dfa2c8>
	 course
	 {'number': '448', 'name': 'Data-Oriented Computing for Mathematicians'}
	 <Element semester at 0x7f7178015688>
		 semester
		 {}
		 Fall 2018
	 <Element semester at 0x7f7178015288>
		 semester
		 {}
		 Spring 2017
<Element course at 0x7f717800c808>
	 course
	 {'number': '309', 'name': 'Linear Algebra'}
	 <Element semester at 0x7f7179dfa2c8>
		 semester
		 {}
		 "Spring 2018"