我们可以在XML文件中使用数字作为文本节点吗?
我们可以在XML文件中使用数字作为文本节点吗? 比如说我们可以在XML文件中使用数字作为文本节点吗?,xml,Xml,我们可以在XML文件中使用数字作为文本节点吗? 比如说 <2> <abi>Zen</abi> </2> 禅 它给出的错误如下XML元素必须遵循以下命名规则: * Names can contain letters, numbers, and other characters * Names cannot start with a number or punctuation character * Names cannot start wit
<2>
<abi>Zen</abi>
</2>
禅
它给出的错误如下XML元素必须遵循以下命名规则:
* Names can contain letters, numbers, and other characters
* Names cannot start with a number or punctuation character
* Names cannot start with the letters xml (or XML, or Xml, etc)
* Names cannot contain spaces
1. Names can contain letters, numbers, and other characters
2. **Names cannot start with a number or punctuation character**
3. Names cannot start with the letters xml (or XML, or Xml, etc)
4. Names cannot contain spaces
阅读以下内容:
符号和字符(&)和
左尖括号()可以用
字符串“”和必须,用于
兼容性,可以使用
“”或字符引用
当它出现在字符串“]]>”中时
在内容中,当该字符串不是
标记CDATA区域的结束
简短回答:没有
不过,你可以用这样的东西
<element2>
<abi>Zen</abi>
</element2>
禅
但这将导致一个非常丑陋的XML模式,在这个模式中,您最终将被限制在最大数量的元素上
我认为你应该这样做:
<element number="2">
<abi>Zen</abi>
</element>
禅
不,您不能使用
XML命名规则
XML元素必须遵循以下命名规则:
* Names can contain letters, numbers, and other characters
* Names cannot start with a number or punctuation character
* Names cannot start with the letters xml (or XML, or Xml, etc)
* Names cannot contain spaces
1. Names can contain letters, numbers, and other characters
2. **Names cannot start with a number or punctuation character**
3. Names cannot start with the letters xml (or XML, or Xml, etc)
4. Names cannot contain spaces
可以使用任何名称,不保留任何单词
根据第二条规则,您不能将数字用作XML文件中的文本节点,因为它的意思是标记以数字开头
实际上这是可以做到的-您必须将XML标记中的第一个数字字符替换为,其中:
- 0=x0030
- 1=x0031
- 2=x0032
- 3=x0033
- 4=x0034
- 5=x0035
- 6=x0036
- 7=x0037
- 8=x0038
- 9=x0039
可以定义为:
<_x0031_11222>
</_x0031_11222>
Java内容存储库—ApacheJackrabbit项目以这种方式处理节点名称。它并不漂亮,但它回答了这个问题。该XML中的文本节点是“Zen”。您真正想知道的是,是否可以使用数字作为元素名。