August 8, 2026
XML Namespaces Explained: What xmlns Actually Does
An XML namespace prevents element name collisions when documents from different sources or schemas get combined — the xmlns attribute binds a prefix to a URI, and any element using that prefix is understood to belong to that specific vocabulary, not just share a name with an unrelated one.

The collision problem namespaces solve
A <title> element could mean a book's title in one schema and a person's job title in another. If a single document needs to combine data from both — a book catalog that also lists contributor bios, say — a parser has no way to tell the two <title> elements apart from the tag name alone. That's the exact problem namespaces exist to solve.
How the syntax actually works
<catalog xmlns:book="http://example.com/books" xmlns:person="http://example.com/people"> <book:title>Dune</book:title> <person:title>Editor</person:title> </catalog>
The xmlns:book and xmlns:person attributes bind each prefix to a distinct URI — which doesn't need to point to a real, fetchable resource; it just needs to be a unique identifier. Every element using the book: or person: prefix is now unambiguously scoped to its own vocabulary, even though both still use the word "title."
Where you'll actually run into this
SOAP APIs, RSS/Atom feeds, and SVG embedded in HTML all lean on namespaces routinely — SOAP specifically uses them to combine the envelope, header, and body vocabularies from different specs in a single message. If you're converting XML from one of these sources into JSON, namespace prefixes typically get folded directly into the resulting key names (book:title becomes a literal key like "book:title"), since JSON has no equivalent namespace concept to preserve the distinction structurally.
Want to try this yourself?
Open XML to JSON →