Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we specify namespace in android xml file?

When we write a xml based layout in Android we use the string "xmlns:android="http://schemas.android.com/apk/res/android".

From the books I read it says that this is a namespace, but why do we use this? The link doesn't even exist. So what is the use of this?

like image 896
Vinoth Avatar asked May 02 '11 11:05

Vinoth


People also ask

Why do we use namespace in XML?

One of the primary motivations for defining an XML namespace is to avoid naming conflicts when using and re-using multiple vocabularies. XML Schema is used to create a vocabulary for an XML instance, and uses namespaces heavily.

What is namespace in Android XML?

An XML Namespace has the properties: Namespace URI: Namespace name expressed as a URI to which the prefix is bound. prefix: syntactically, this is the part of the attribute name following the XMLConstants. XMLNS_ATTRIBUTE ("xmlns") in the Namespace declaration.

What is namespace in SOAP XML?

An XML namespace is a means of qualifying element and attribute names to disambiguate them from other names in the same document. This section provides a brief description of XML namespaces and how they are used in SOAP. For complete information, see http://www.w3.org/TR/REC-xml-names/

What is namespace URI in XML?

A namespace name is a uniform resource identifier (URI). Typically, the URI chosen for the namespace of a given XML vocabulary describes a resource under the control of the author or organization defining the vocabulary, such as a URL for the author's Web server.


1 Answers

From developer.android.com

xmlns:android

Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".

xmlns:android is for identification that this xml is used for android, not for other function.

Namespaces uniquely identify code/libraries. If I write an api that uses all the same names and such as the android api the only way to distinguish between my api and android api is to use the android namespace, or mine.

You can further refer http://en.wikipedia.org/wiki/XML_namespace

like image 191
Kartik Domadiya Avatar answered Oct 14 '22 05:10

Kartik Domadiya