本文介绍了引用XML。单人或双人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我听说用单引号来包围XML属性值是一种不好的风格。这是正确的?我应该总是写:
<元素attr =value>
或者可以接受:
< element attr ='value'>
或者使用哪种风格并不重要?
解决方案
两者都是合法的。选择一个并坚持下去。没关系。
从:
AttValue :: =''([^<&] | Reference)*' '
|''([^&'] | Reference)*'
显示两者都是有效的,就像在一个元素,每个属性中混合两种样式一样(尽管我建议在任何单个文档/一组文档中保持一致。)
I've heard that using single quotes to surround XML attribute values is a "bad style". Is this correct?
Should I always write:
<element attr="value">
Or is it acceptable to write:
<element attr='value'>
Or does it not matter which style I use?
解决方案
Both are legal. Choose one and stick with it. It doesn't matter.
From the spec:
AttValue ::= '"' ([^<&"] | Reference)* '"'
| "'" ([^<&'] | Reference)* "'"
Showing that both are valid, as is mixing the two styles within an element, per attribute (though I suggest being consistent within any single document/set of documents).
这篇关于引用XML。单人或双人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!