Understanding XML Namespaces

Why namespaces?

Namespaces have been a W3C standard since January 1999. The idea behind namespaces is simple: We need a way to fully qualify XML element and attribute names to prevent from confusing two elements that have the same name but mean different things.

For example, you might have an accounting application that uses an element called <schedule> to mean an accounting schedule. A time management application might use the same element <schedule> to mean a time schedule. You might need to put accounting and time management data in one XML document. For example, you might be keeping track of all project information including accounting and project timeline in the same document. Now each application would not be able to tell which <schedule> element belongs to it. To solve this problem, you could prefix each <schedule> element with a unique prefix that indicates to which application it belongs. For example <accounting:schedule> and <time:schedule> would make things much clearer. In this example accounting and time are namespaces.

Namespaces are simply a way to uniquely identify elements and attributes within a document.

You might also like...


About the author

Yasser Shohoud United States

Yasser started programming at the age of 12 when he wrote his first text-based game on a Commodore PET. He's since moved to IBM mainframes then to Microsoft technologies and has worked as System...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon