问题
如果XML有非法字符比如 "·",或者HTML标签<br/>。XML在解析的过程中就会出错。就无法正常解析,或者把xml反射成实体。
有些字符,像(<)这类的,对HTML标准通用标记语言下的一个应用)来说是有特殊意义的,所以这些字符是不允许在文本中使用的。要在HTML中显示(<)这个字符,我们就必须使用实体字符。
解决的办法
如果这些非法字符或者HTML标签不是我们需要的可以用striing.Replace("非法字符","")把它替换为空。
如果这些字符是必须的。我们可以替换成对应的实体。
实体参考
 
 

1实体字符

一些字符在 HTML 中是预留的,拥有特殊的含义,比如小于号‘<’用于定义 HTML 标签的开始。如果我们希望浏览器正确地显示这些字符,我们必须在 HTML 源码中插入字符实体。
字符实体有三部分:一个和号‘&’和一个实体名称(或者一个‘#’ 和一个实体编号),以及一个分号‘;’。
要在 HTML 文档中显示小于号,我们需要这样写:&lt; 或者‘<’最后的效果则是<
使用实体名称而不是实体编号的好处在于,名称相对来说更容易记忆。而这么做的坏处是,并不是所有的浏览器都支持最新的实体名称,然而几乎所有的浏览器对实体编号的支持都很好。
注意:实体对大小写敏感。 

2ASCI

结果
描述
实体名称
实体编号
"
quotation mark
&quot;
"
'
apostrophe
&apos;
'
&
ampersand
&amp;
&
<
less-than
&lt;
<
>
greater-than
&gt;
>

3符号实体编辑

结果
描述
实体名称
实体编号
  
non-breaking space
&nbsp;
 
¡
inverted exclamation mark
&iexcl;
¡
cent
&cent;
¢
pound
&pound;
£
¤
currency
&curren;
¤
yen
&yen;
¥
|
broken vertical bar
&brvbar;
¦
§
section
&sect;
§
¨
spacing diaeresis
&uml;
¨
©
copyright
&copy;
©
a
feminine ordinal indicator
&ordf;
ª
«
angle quotation mark (left)
&laquo;
«
¬
negation
&not;
¬
  
soft hyphen
&shy;
 
®
registered trademark
&reg;
®
ˉ
spacing macron
&macr;
¯
°
degree
&deg;
°
±
plus-or-minus
&plusmn;
±
2
superscript 2
&sup2;
²
3
superscript 3
&sup3;
³
spacing acute
&acute;
´
μ
micro
&micro;
µ
paragraph
&para;
·
middle dot
&middot;
·
¸
spacing cedilla
&cedil;
¸
1
superscript 1
&sup1;
¹
o
masculine ordinal indicator
&ordm;
º
»
angle quotation mark (right)
&raquo;
»
¼
fraction 1/4
&frac14;
¼
½
fraction 1/2
&frac12;
½
¾
fraction 3/4
&frac34;
¾
¿
inverted question mark
&iquest;
¿
×
multiplication
&times;
×
÷
division
&divide;
÷

4字符实体编辑

结果
描述
实体名称
实体编号
à
capital a, grave accent
&Agrave;
À
á
capital a, acute accent
&Aacute;
Á
Â
capital a, circumflex accent
&Acirc;
Â
Ã
capital a, tilde
&Atilde;
Ã
Ä
capital a, umlaut mark
&Auml;
Ä
Å
capital a, ring
&Aring;
Å
Æ
capital ae
&AElig;
Æ
Ç
capital c, cedilla
&Ccedil;
Ç
è
capital e, grave accent
&Egrave;
È
é
capital e, acute accent
&Eacute;
É
ê
capital e, circumflex accent
&Ecirc;
Ê
Ë
capital e, umlaut mark
&Euml;
Ë
ì
capital i, grave accent
&Igrave;
Ì
í
capital i, acute accent
&Iacute;
Í
Î
capital i, circumflex accent
&Icirc;
Î
Ï
capital i, umlaut mark
&Iuml;
Ï
D
capital eth, Icelandic
&ETH;
Ð
Ñ
capital n, tilde
&Ntilde;
Ñ
ò
capital o, grave accent
&Ograve;
Ò
ó
capital o, acute accent
&Oacute;
Ó
Ô
capital o, circumflex accent
&Ocirc;
Ô
Õ
capital o, tilde
&Otilde;
Õ
Ö
capital o, umlaut mark
&Ouml;
Ö
Ø
capital o, slash
&Oslash;
Ø
ù
capital u, grave accent
&Ugrave;
Ù
ú
capital u, acute accent
&Uacute;
Ú
Û
capital u, circumflex accent
&Ucirc;
Û
ü
capital u, umlaut mark
&Uuml;
Ü
Y
capital y, acute accent
&Yacute;
Ý
T
capital THORN, Icelandic
&THORN;
Þ
ß
small sharp s, German
&szlig;
ß
à
small a, grave accent
&agrave;
à
á
small a, acute accent
&aacute;
á
a
small a, circumflex accent
&acirc;
â
ã
small a, tilde
&atilde;
ã
ä
small a, umlaut mark
&auml;
ä
å
small a, ring
&aring;
å
æ
small ae
&aelig;
æ
ç
small c, cedilla
&ccedil;
ç
è
small e, grave accent
&egrave;
è
é
small e, acute accent
&eacute;
é
ê
small e, circumflex accent
&ecirc;
ê
ë
small e, umlaut mark
&euml;
ë
ì
small i, grave accent
&igrave;
ì
í
small i, acute accent
&iacute;
í
î
small i, circumflex accent
&icirc;
î
ï
small i, umlaut mark
&iuml;
ï
e
small eth, Icelandic
&eth;
ð
ñ
small n, tilde
&ntilde;
ñ
ò
small o, grave accent
&ograve;
ò
ó
small o, acute accent
&oacute;
ó
ô
small o, circumflex accent
&ocirc;
ô
õ
small o, tilde
&otilde;
õ
ö
small o, umlaut mark
&ouml;
ö
ø
small o, slash
&oslash;
ø
ù
small u, grave accent
&ugrave;
ù
ú
small u, acute accent
&uacute;
ú
û
small u, circumflex accent
&ucirc;
û
ü
small u, umlaut mark
&uuml;
ü
y
small y, acute accent
&yacute;
ý
t
small thorn, Icelandic
&thorn;
þ
ÿ
small y, umlaut mark
&yuml;
ÿ
显示结果
描述
实体名称
实体编号
  
空格
&nbsp;
 
<
小于号
<
<< p=""><!--
>
大于号
>
>
&
和号
&amp;
&
"
引号
&quot;
"
'
撇号
&apos; (IE不支持)
'
&cent;
¢
&pound;
£
人民币
&yen;
¥
           

XML中的非法字符转化成实体的更多相关文章

  1. xml中的非法字符

    今使用Jdom生成xml文件的时候,总是出现0x0,0x8为非法字符,经过搜索,问题原因及解决方法如下: 原因:xml中需要过滤的字符分为两类,一类是不允许出现在xml中的字符,这些字符不在xml的定 ...

  2. 华为2013年西安java机试题目:如何过滤掉数组中的非法字符。

    这道题目为记忆版本: 题目2描述: 编写一个算法,过滤掉数组中的非法字符,最终只剩下正式字符. 示例:输入数组:“!¥@&HuaWei*&%123” 调用函数后的输出结果,数组:“Hu ...

  3. SVN Files 的值“ < < < < < < < .mine”无效。路径中具有非法字符。

    错误 1 Files 的值“ < < < < < < < .mine”无效.路径中具有非法字符.     今天使用SVN进行更新的时候,出现了如上问题,想起卓 ...

  4. 错误 1 Files 的值“ < < < < < < < .mine”无效。路径中具有非法字符。

    错误 1 Files 的值“ < < < < < < < .mine”无效.路径中具有非法字符.     今天使用SVN进行更新的时候,出现了如上问题,想起卓 ...

  5. Linux c字符串中不可打印字符转换成16进制

    本文由 www.169it.com 搜集整理 如果一个C字符串中同时包含可打印和不可打印的字符,如果想将这个字符串写入文件,同时方便打开文件查看或者在控制台中打印出来不会出现乱码,那么可以将字符串中的 ...

  6. SVN提交出现“< < < < < < < .mine’无效,路径中具有非法字符”的问题

    使用SVN提交或更新后经常会出现”Files 的值’< < < < < < < .mine’无效.路径中具有非法字符”的错误.查阅了下资料,是因为:你更改了一 ...

  7. 解决 Files 的值"<<<<<<< HEAD"无效。路径中具有非法字符

    通常我们使用版本控制后会出现诸如此类的问题,此时从vs工具找错误和调试是无法找到问题的,也不影响项目的运行,但是有错误就是得解决.原因是版本控制导致文件的路径出现问题. 解决 Files 的值&quo ...

  8. SVN版本冲突中 Files 的值“ < < < < < < < .mine”无效路径中具有非法字符的解决办法

    .NET 中 SVN版本冲突中 Files 的值“ < < < < < < < .mine”无效路径中具有非法字符的解决办法: 一. 1.将项目逐个进行编译, ...

  9. SVN版本冲突,导致出现Files 的值“ < < < < < < < .mine”无效。路径中具有非法字符。

    SVN版本冲突,导致出现Files 的值“ < < < < < < < .mine”无效.路径中具有非法字符. 右键编辑.... 打开并删除含有'<&l ...

随机推荐

  1. 针对各种浏览器css不兼容的写法

    /*针对谷歌浏览器内核支持的CSS样式*/@media screen and (-webkit-min-device-pixel-ratio:0) { 样式 } /*针对IE6特制识别的CSS样式*/ ...

  2. [SAP ABAP开发技术总结]报表事件

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  3. How much do we need to learn to be a Self-driving Car Engineer?

    Before everything we need programming skills in C++ and Python. One of the suggested book for C++ le ...

  4. CSS笔记(十一)CSS3之边框

    参考:http://www.w3school.com.cn/css3/css3_border.asp 圆角边框 <!DOCTYPE html> <html> <head& ...

  5. GATK3.2.2小结(转载)

    http://blog.csdn.net/skenoy/article/details/38346489 经过几天的摸索和网上资料的查询对GATK软件有点小心得,现总结如下: 1. fasta文件最好 ...

  6. placeholder在ie浏览器里不显示的问题解决

    <script type="text/javascript"> if( !('placeholder' in document.createElement('input ...

  7. 2013 Multi-University Training Contest 2

    HDU-4611 Balls Rearrangement 题意:具体题意不大清楚,最后要处理一个这样的表达式:sum{ |i % a - i % b| },0 <= i < N 的取值很大 ...

  8. sciencesoftware科学软件

    软件名称 软件分类 二级分类 更新日期 下载 GMS(Groundwater Modeling Solution) 10 地球地理软件 水资源 2014-09-28 下载 Data Desk 7 经济 ...

  9. POJ 2063 Investment 完全背包

    题目链接:http://poj.org/problem?id=2063 今天果然是卡题的一天.白天被hdu那道01背包的变形卡到现在还没想通就不说了,然后晚上又被这道有个不大也不小的坑的完全背包卡了好 ...

  10. composer 安装yii插件 fontawesome

    国外站点 http://fontawesome.io/ 国内站点 http://fontawesome.dashgame.com/ Installation The preferred way to ...