use XML Namespaces(refers from MSDN)
关键字: xml, xmlns
This topic provides basic information about XML namespaces.
What Is an XML Namespace?
An XML namespace is a collection of names that can be used as element or attribute names in an XML document. The namespace qualifies element names uniquely on the Web in order to avoid conflicts between elements with the same name. The namespace is identified by some Uniform Resource Identifier (URI), either a Uniform Resource Locator (URL), or a Uniform Resource Name (URN), but it doesn't matter what, if anything, it points to. URIs are used simply because they are globally unique across the Internet.
Namespaces can be declared either explicitly or by default. With an explicit declaration, you define a shorthand, or prefix, to substitute for the full name of the namespace. You use this prefix to qualify elements belonging to that namespace. Explicit declarations are useful when a node contains elements from different namespaces. A default declaration declares a namespace to be used for all elements within its scope, and a prefix is not used.
How Do I Declare an Explicit Namespace?
The following explicit declaration declares bk and money to be shorthand for the full names of their respective namespaces. The xmlns attribute is an XML keyword for a namespace declaration.
<BOOKS>
<bk:BOOK xmlns:bk="urn:example.microsoft.com:BookInfo"
xmlns:money="urn:Finance:Money">
<bk:TITLE>Creepy Crawlies</bk:TITLE>
<bk:PRICE money:currency="US Dollar">22.95</bk:PRICE>
</bk:BOOK>
</BOOKS>
How Do I Declare a Default Namespace?
A namespace declared without a prefix becomes the default namespace for the document. All elements and attributes in the document that do not have a prefix will then belong to the default namespace. The following example declares that the <BOOK> element and all elements and attributes within it (<TITLE>, <PRICE>, currency) are from the namespace urn:example.microsoft.com:BookInfo.
<BOOK xmlns="urn:example.microsoft.com:BookInfo"> <TITLE>Creepy Crawlies</TITLE> <PRICE currency="US Dollar">22.95</PRICE> </BOOK>
发表评论
- 浏览: 4122 次
- 性别:

- 来自: 深圳

- 详细资料
搜索本博客
最近加入圈子
链接
最新评论
-
请问现在从事MES系统开发 ...
补充一下,是在电子制造行业做MES系统开发
-- by feiyu367 -
一个很牛逼的IT精英回忆录 ...
幅度好大哦 呵呵
-- by libojacky -
一个很牛逼的IT精英回忆录 ...
-- by zsk_china -
一个很牛逼的IT精英回忆录 ...
-- by dreaminjava -
一个很牛逼的IT精英回忆录 ...
真棒 真棒 真棒。。
-- by liuyanttkl






评论排行榜