“xmlns"是什么意思?在 XML 中是什么意思? [英] What does "xmlns" in XML mean?

查看:84
本文介绍了“xmlns"是什么意思?在 XML 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XML 文件中看到以下行:

I saw the following line in an XML file:

xmlns:android="http://schemas.android.com/apk/res/android"

我还在我遇到的许多其他 XML 文件中看到了 xmlns.

I have also seen xmlns in many other XML files that I've come across.

这是什么?

推荐答案

它定义了一个 XML 命名空间.

在您的示例中,命名空间前缀android",命名空间 URIhttp://schemas.android.com/apk/res/android"

In your example, the Namespace Prefix is "android" and the Namespace URI is "http://schemas.android.com/apk/res/android"

在文档中,您会看到如下元素:<android:foo/>

In the document, you see elements like: <android:foo />

将命名空间前缀视为具有完整命名空间 URI 的短名称别名的变量.它相当于编写 <http://schemas.android.com/apk/res/android:foo/> 关于它的含义"当 XML 解析器读取文档时.

Think of the namespace prefix as a variable with a short name alias for the full namespace URI. It is the equivalent of writing <http://schemas.android.com/apk/res/android:foo /> with regards to what it "means" when an XML parser reads the document.

注意:您实际上不能使用完整的命名空间 URI 代替 XML 实例文档中的命名空间前缀.

NOTE: You cannot actually use the full namespace URI in place of the namespace prefix in an XML instance document.

查看有关命名空间的本教程:http://www.sitepoint.com/xml-命名空间解释/

Check out this tutorial on namespaces: http://www.sitepoint.com/xml-namespaces-explained/

这篇关于“xmlns"是什么意思?在 XML 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆