The background is several times a month I will be grabbing an XML file with a tremendous amount of information. I only need 2 items from the XML, Last Name and Code number. I've written my XML parser which seems to work right now. It displays all the information I need but I cannot figure out the sorting.
If I get it sorted, it places the numerical codes first but it seems to only check the first digit so no real sorting happens. I really wanted it sorted by Last name which there could be several of the same last name with different codes next to them.
I've tried Google, maybe I'm tired and can't tighten up by search criteria but I keep getting results for numerical sorting when I want alphabetical first with the numerical next to it.
What I want is:
import xml.etree.ElementTree as etree import os #define data file data_file = 'ticketsexport.xml' xmlD = etree.parse(data_file) #Loops through all tickets and only prints Last Name and Code number. for ticket in xmlD.iter('Ticket'): lname = ticket.find('LastName').text code = ticket.find('Code').text print lname, code