字符实体引用-是否为数字? [英] Character entity references - numeric or not?

查看:76
本文介绍了字符实体引用-是否为数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我知道我可以将&符号表示为&&.

So, I know that I can represent an ampersand as & or &.

我发现,至少有一种解析XML的方法不允许使用基于缩写的样式-只能使用数字.有最佳实践吗?根据我的经验,我想指导我的团队使用数字版本,但是一个实例似乎不足以说服它们.

I have found that at least one method of parsing XML does not allow for the abbreviation-based style - only numeric. Is there a best-practice? I want to instruct my team to use the numeric versions because of my experience, but one instance hardly seems like enough reason to convince them.

我们应该采用哪种方法?

Which method should we favor?

推荐答案

对于我们对于© 熟悉的符号名称等等,因为存在实体是因为它们在HTML DTD中的外观,请在此处 http: //www.w3.org/TR/html4/sgml/entities.html (尽管我认为大多数浏览器都已加入).

The symbolic names we're familiar with for ©, etc. for entities exist because of their appearance in the HTML DTD, here http://www.w3.org/TR/html4/sgml/entities.html (although I think most browsers have this baked in).

因此,如果您使用的是(X)HTML,请正确设置文档类型,然后按照w3.org上的链接访问XHTML以查看可用的实体.

Therefore, if you are using (X)HTML, get your doctype right, and then follow the links on w3.org to XHTML to see the entities available.

就最佳实践而言,大多数人发现符号名称更易于理解,并会在可用时使用它们.我会建议.

As far as best practices, most people find the symbolic names easier to understand and will use them when available. I would recommend that.

唯一不这样做的原因是,在非常老的浏览器中,有时会出现实体不起作用的情况-但我认为情况不再如此.

The only reason not to is that there used to be cases in very old browsers when entities wouldn't work-- but I don't believe this is the case any more.

这篇关于字符实体引用-是否为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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