XML Local Namespace

A brief overview of local namepspaces.

In the previous lesson, we created a namespace to avoid a name conflict between the elements of two documents we wanted to combine. When we defined the namespace, we defined it against the root element. This meant that the namespace was to be used for the whole document, and we prefixed all child elements with the same namespace.

You can also define namespaces against a child node. This way, you could use multiple namespaces within the same document if required.

Example Local Namespace

Here, we apply the namespace against the title element only:

Multiple Namespaces

You could also have multiple namespaces within your XML document. For example, you could define one namespace against the root element, and another against a child element.

Example: