O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Multiple Namespaces in a Document

Namespaces remove ambiguity from element type names. This assists the exchange of XML documents between users, but it also allows elements from different namespaces—in context implicitly different XML application languages—to be mixed in the same document.

You can mix elements in the same document if you understand the scope of namespaces.

Scope of Namespaces

The scope of a namespace is limited to all elements nested inside the element on which the namespace was declared. However, the namespace may be altered by a namespace declaration on any of the nested elements.

Look at a simple example:

 <somePrefix:anElement xmlns:somePrefix= http://www.XMML.com/someNamespace> <anotherPrefix:anElement xmlns:anotherPrefix="http://www.XMML.com/anotherNamespace> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required