XML 中的引号.单人还是双人? [英] Quotes in XML. Single or double?

查看:10
本文介绍了XML 中的引号.单人还是双人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说使用单引号将 XML 属性值括起来是一种不好的风格".这是正确的吗?

I've heard that using single quotes to surround XML attribute values is a "bad style". Is this correct?

我应该一直写吗:

<element attr="value">

或者可以这样写:

<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.

来自规范:

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 中的引号.单人还是双人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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