问题描述
是否可以在XML标记内注释一个或几个属性?类似于C中的/* */
.
Is it possible to comment one or several attributes inside an XML tag? Something like /* */
from C.
我尝试使用<!-- -->
,但未成功.
I have tried using <!-- -->
, but it was unsuccessful.
<element
attribute1="value1"
attribute2="value2"
<!-- attribute3="value3" (commented value) -->
>
推荐答案
否,这是不可能的. XML开放标记中不允许注释.根据您的应用程序,您可以通过在属性名称前加上"_"作为前缀来注释掉"属性,也可以不这样做(如果XML是根据架构进行验证的,或者已解析了所有属性).由于允许使用空格,并且大多数编辑器都支持行操作,因此您可以通过以下方式轻松地注释"多个属性:
No, this isn't possible. Comments are not allowed in an XML open tag. Depending on your application, you might get away with "commenting out" the attributes by prefixing their names with "_", or you might not (if the XML is validated against a schema or all attributes are parsed). Because whitespace is allowed, and most editors support line operations, you can "comment" multiple attributes easily this way:
<element
_attr1="value1"
_attr2="value2"
_attr3="value3"
>
但是这些属性仍然是文档的一部分.
But these attributes are still part of the document.
这篇关于如何注释XML标记内的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!