如何评论xml标签内的属性? [英] How to comment attribute(s) inside xml tag?

查看:159
本文介绍了如何评论xml标签内的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在xml标记中注释一个或多个属性?
像/ * * /。我试过<


解决方案

不,这是不可能的。 XML开放标记中不允许使用注释。根据您的应用程序,您可能会通过使用_作为其名称前缀注释掉属性,或者您可能不会(如果XML针对模式验证或所有属性都已解析)不会。因为允许使用空格,并且大多数编辑器支持行操作,所以可以通过这种方式轻松注释多个属性:

 code>< element 
_attr1 =value1
_attr2 =value2
_attr3 =value3
>

但这些属性仍然是文档的一部分。


Is it possible to comment one or several attributes inside xml tag? Something like /* */. I have tried < !-- -- > it was unsuccessful.

解决方案

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标签内的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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