假设我有以下 XML 文档,它没有定义默认的命名空间,并且“信息”元素没有以任何命名空间前缀作为前缀。我的问题是, 1. 命名空间元素“信息”属于什么? 2.有什么方法可以对“信息”元素应用XML模式检查(例如,我想检查信息元素的内容是否为空或使用模式定义的东西)?
<?xml version="1.0" encoding="utf-8"?>
<Information>Hello XML</Information>
提前致谢,
乔治
最佳答案
来自 specification :
If there is no default namespace declaration in scope, the namespace name has no value. The namespace name for an unprefixed attribute name always has no value. In all cases, the local name is local part (which is of course the same as the unprefixed name itself).
所以这里的命名空间实际上是空字符串
""
.
关于xml - 元素在 XML 中属于哪个命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/767220/