In XML, a namespace is used to provide uniquely named elements and attributes in an XML document. XML namespaces are defined in a W3C recommendation and are used to avoid naming conflicts when using and reusing multiple vocabularies. If each vocabulary is given a namespace, the ambiguity between identically named elements or attributes can be resolved. A namespace name is a uniform resource identifier (URI) that typically describes a resource under the control of the author or organization defining the vocabulary, such as a URL for the authors Web server.
Namespace declarations can be made at any element in the XML document, and the scope of a declared namespace begins at the element where it is declared and applies to the entire content of that element, unless overridden by another namespace declaration with the same prefix name. Namespaces can be declared explicitly as attribute nodes named "xmlns" or "xmlns:xxx", or as namespace declarations that correspond one-to-one with the relevant attributes in the source XML document.
A default namespace can also be defined for an element, which saves us from using prefixes in all the child elements. A namespace declared without a prefix becomes the default namespace for the document, and all elements and attributes in the document that do not have a prefix will then belong to the default namespace).
In summary, a namespace in XML is a way to provide uniquely named elements and attributes in an XML document, and it is identified by a URI. Namespace declarations can be made at any element in the XML document, and a default namespace can also be defined for an element.