Ads by ProfitSence

XML NameSpaces

Last Updated on Wednesday 5th Oct 2022

namespaces in xml

XML Namespaces provide a method to avoid element name conflicts.

A namespace is a collection of all the names of elements, types, and attributes in a specific schema

  • In XML, element names are defined by the developer.
  • This often results in a conflict when trying to mix XML documents from different XML applications.
  • Namespaces let the parser know which DTD or schema you’re using so you can use the markup from several different DTDs or schemas in one document.
  • Namespaces are also called vocabularies because they consist of a collection of names and definitions.

namespace xml

Namespace Declaration

When using prefixes in XML, a namespace for the prefix must be defined.

      xmlns:name = "URL">

  • With the c: prefix a qualified namespace.
  • When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace.
    <c:title>XML NameSpaces</c:title>


namespaces xml

  • The purpose of using an URI is to give the namespace a unique name.
					<?xml version="1.0"?>
    <title>Cheaper by the Dozen</title>


What is URI ?

  • A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.
  • The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address.