The country codes from all three parts of ISO 3166 are available in .xml, .csv and .xls formats here: Country Codes Collection
ISO 3166-2:2013 establishes a universally applicable code for the representation of the names of principal administrative divisions of countries and territories included in ISO 3166-1. It is intended to be used in conjunction with ISO 3166-1.
Clauses 4 to 7 of ISO 3166-2:2013 provide the structure for a code for the representation of names of principal administrative divisions, or similar areas, of the countries and geopolitical entities included in ISO 3166-1.
Clause 8 contains a list of names of subdivisions of countries and geopolitical entities, together with the code element developed for each one of them.