XML Namespaces

Namespaces associate element and attribute names with a URI to prevent naming collisions when combining multiple XML vocabularies. The URI is a unique identifier string — it does not need to resolve to a web page.

Syntax

xml-fundamentals
xmlns="URI"          — default namespace
xmlns:prefix="URI"  — prefixed namespace
prefix:element       — qualified name
xmlns=""             — undeclare default namespace

Example

xml-fundamentals
<invoice
  xmlns="http://example.com/invoice"
  xmlns:addr="http://example.com/address"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://example.com/invoice inv.xsd">
  <id>INV-001</id>
  <addr:billing>
    <addr:city>Springfield</addr:city>
  </addr:billing>
</invoice>