Click here to Skip to main content
Click here to Skip to main content
Go to top

State names and abbrev in XML

, 17 Feb 2002
Rate this:
Please Sign up or sign in to vote.
An XML file containing US state and territory names and their two letter abbreviation.
<!-- Add the rest of your HTML here -->


I figured this could come in handy to anyone who needed it so I just threw it together. I got tired of not having a list of states. I so often have to implement a dropdown or validate an input that takes an abbreviation and always have to get the information from some website that has a similar list. So this time I finally got smart and made an XML file out of it. I got the information from the USPS website.

The file uses a very simple structure:

  <state name="ALABAMA" abbreviation="AL" /> 
  <state name="ALASKA" abbreviation="AK" /> 

That's all there is to it. Hope you find this useful.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jason Gerard
Web Developer
United States United States
Jason has been coding professionally since 1998. He is an expert with Java, J2EE, C#, .NET, and VB.

Comments and Discussions

GeneralMy vote of 5 Pinmemberfredatcodeproject29-Feb-12 3:30 
Generalproper function applied ;) Pinmemberandrei_teodorescu18-May-11 22:51 
GeneralYou totally rock! PinmemberKim Finleyson14-Aug-08 11:03 
QuestionWhat about an XML list of world countries? PinmemberJesse Sedwick2-Jul-08 9:37 
Generalthanx Pinmembersuniltauro5-Oct-07 5:15 
QuestionI need some type of state list and more importantly, a city list Pinmembertejas559-Sep-07 18:27 
I'm starting a site similar to craigslist and need some type of US city file to import because entering manually would take until the end of time. I can do the 50 states but the cities would be impossible. My admin page has the following information regarding importing data for locations but I don't understand it. My site is PHP scripts. Any help would be appreciated.
Uploaded file should contain lines of the form:
GeneralAWESOME Pinmemberregwood7927-Oct-06 9:01 
GeneralThanks! Pinmemberlexzxzx24-Apr-06 17:05 
GeneralCapitals PinsussAnonymous21-Oct-02 3:34 
GeneralRe: Capitals PinsussAnonymous16-Apr-04 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 18 Feb 2002
Article Copyright 2002 by Jason Gerard
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid