博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XML中特殊字符的处理
阅读量:4136 次
发布时间:2019-05-25

本文共 2966 字,大约阅读时间需要 9 分钟。

What are the special characters in XML?

For normal text (not markup), there are no special characters: just make sure your document refers to the correct encoding scheme for the language and/or writing system you want to use, and that your computer correctly stores the file using that encoding scheme. See for a longer explanation.

If your keyboard will not allow you to type the characters you want, or if you want to use characters outside the limits of the encoding scheme you have chosen, you can use a symbolic notation called ‘entity referencing’. Entity references can either be numeric, using the decimal or hexadecimal code point for the character (eg if your keyboard has no Euro symbol (€) you can type &#8364;); or they can be character, using an established name which you declare in your DTD (eg <!ENTITY euro "&#8364;">) and then use as &euro; in your document. If you are using a Schema, you must use the numeric form for all except the five below because Schemas have no way to make character entity declarations.

If you use XML with no DTD, then these five character entities are assumed to be predeclared, and you can use them without declaring them:

&lt;

The less-than character (<) starts element markup (the first character of a start-tag or an end-tag).

&amp;

The ampersand character (&) starts entity markup (the first character of a character entity reference).

&gt;

The greater-than character (>) ends a start-tag or an end-tag.

&quot;

The double-quote character (") can be symbolised with this character entity reference when you need to embed a double-quote inside a string which is already double-quoted.

&apos;

The apostrophe or single-quote character (') can be symbolised with this character entity reference when you need to embed a single-quote or apostrophe inside a string which is already single-quoted.

If you are using a DTD then you must declare all the character entities you need to use (if any), including any of the five above that you plan on using (they cease to be predeclared if you use a DTD). If you are using a Schema, you must use the numeric form for all except the five above because Schemas have no way to make character entity declarations.

Warning

There are circumstances where you can use special characters as themselves, such as in . Most control characters are prohibited in XML: see the for exact details.

There are no reserved words as such in the user namespace of XML: you can call an element element and an attribute attribute and so on as in the following (ludicrous) example:

]>
bar

where the file SYSTEM contains the declaration: <!ELEMENT ELEMENT (#PCDATA)> and the file ENTITY does not even exist.

There are keywords like DOCTYPE and IMPLIED which are reserved Names, but they are prefixed by a flag character (the Markup Declaration Open character or the Reserved Name Indicator) so that they cannot be confused with user-specified Names.

 

转自:

转载地址:http://vkavi.baihongyu.com/

你可能感兴趣的文章
【视频教程】Javascript ES6 教程27—ES6 构建一个Promise
查看>>
【5分钟代码练习】01—导航栏鼠标悬停效果的实现
查看>>
127个超级实用的JavaScript 代码片段,你千万要收藏好(中)
查看>>
8种ES6中扩展运算符的用法
查看>>
【视频教程】Javascript ES6 教程28—ES6 Promise 实例应用
查看>>
127个超级实用的JavaScript 代码片段,你千万要收藏好(下)
查看>>
【web素材】03-24款后台管理系统网站模板
查看>>
Flex 布局教程:语法篇
查看>>
年薪50万+的90后程序员都经历了什么?
查看>>
2019年哪些外快收入可达到2万以上?
查看>>
【JavaScript 教程】标准库—Date 对象
查看>>
前阿里手淘前端负责人@winter:前端人如何保持竞争力?
查看>>
【JavaScript 教程】面向对象编程——实例对象与 new 命令
查看>>
我在网易做了6年前端,想给求职者4条建议
查看>>
SQL1015N The database is in an inconsistent state. SQLSTATE=55025
查看>>
RQP-DEF-0177
查看>>
Linux查看mac地址
查看>>
Linux修改ip
查看>>
MySQL字段类型的选择与MySQL的查询效率
查看>>
Java的Properties配置文件用法【续】
查看>>