xml - 设置我自己的 XML 命名空间?

标签 xml xml-namespaces

如何设置我自己的 XML 命名空间?

最佳答案

只需在根标记中(或任何需要命名空间的地方)定义一个命名空间。示例:

<root xmlns:ns="some_identifier">

ns 和标识符可以是(几乎)任何东西。 See this quote :

What Do Namespace Names Point At?

One of the confusing things about all this is that namespace names are URLs; it's easy to assume that since they're Web addresses, they must be the address of something. They're not; these are URLs, but the namespace draft doesn't care what (if anything) they point at. Think about the example of the XML.com programmer looking for book titles; that works fine without the namespace name pointing at anything.

The reason that the W3C decided to use URLs as namespace names is that they contain domain names (e.g. www.xml.com), which work globally across the Internet.

Wikipedia article信息量也很大。

我希望您知道您需要命名空间只是为了区分具有相同名称的标签。

关于xml - 设置我自己的 XML 命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5071948/

相关文章:

flash - 无法解析<local :chatters> to a component implementation

wpf - XAML 命名空间 : winfx vs netfx

xml - 从多列的表中提取 html 链接

java - 滚动不起作用时工具栏自动隐藏和显示

android - 获取对外部库 xml 模块的引用

c# - XPath : Get nodes where child node contains an attributeHow to select node that have and attribute and whose parent have another attribute in c#

java - 如何将 Java 的 XPath 库与 XML 命名空间结合使用?

javascript - 无法使用命名空间和 javascript 解析 Xml

java - Spring 3 applicationContext-security-JDBC.xml 有 bean :bean not bean?

c# - 从具有相同名称的多个元素和 xml 中另一个元素的属性值获取属性值