XML's power comes from its flexibility, the fact that you and I and millions of other people can define our own tags to describe our data. Remember the sample XML document for a person's name and address? That document includes the <title> element for a person's courtesy title, a perfectly reasonable choice for an element name. If you run an online bookstore, you might create a <title> element for the title of a book. If you run an online mortgage company, you might create a <title> element for the title to a piece of property. All of those are reasonable choices, but all of them create elements with the same name. How do you tell if a given <title> element refers to a person, a book, or a piece of property? With namespaces.
To use a namespace, you define a namespace prefix and map it to a particular string. Here's how you might define namespace prefixes for our three <title> elements:
In this example, the three namespace prefixes are addr, books, and mortgage. Notice that defining a namespace for a particular element means that all of its child elements belong to the same namespace. The first <title> element belongs to the addr namespace because its parent element, <addr:Name>, does.
One final point: The string in a namespace definition is just a string. Yes, these strings look like URLs, but they're not. You could define xmlns:addr="mike" and that would work just as well. The only thing that's important about the namespace string is that it's unique; that's why most namespace definitions look like URLs. The XML parser does not go to http://www.zyx.com/books/ to search for a DTD or schema, it simply uses that text as a string. It's confusing, but that's how namespaces work.