The reader interface


import libxml2

input = libxml2.inputBuffer(open("ex2.xml"))
reader = input.newTextReader("ex2.xml")
ret = reader.Read()
while ret == 1:
    print reader.Name()
    ret = reader.Read()

See example 2, XML