XML中遇到特殊字符无法解析的问题

前端之家收集整理的这篇文章主要介绍了XML中遇到特殊字符无法解析的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今天非常的郁闷,用xml做配置文件,出现了无法解析的问题。现把我的配置文件分享出来:

  <webs>
          <web id="rzzl_chinazlxxw" url='http://chinarents.com/corp/company_search.PHP?page=1&firstid=1&twoid=10&threeid=169'>
            <urls>
              <url id="child_url"><![CDATA[(?isu)<div[^>]+bgLine[^>]+><a href="\.\.(\/shop\/about.*?contact)"\s+class[^>]+blackLink]]></url>
            </urls>

             <events>
               <event id="url" url="http://chinarents.com/corp/company_search.PHP?page=###&firstid=1&twoid=10&threeid=169" min="2" max="23"></event>
             </events>
  </web>

当解析xml的时候,说有特殊的字符,解析失败。我当时第一反应就是可能因为"&"而引起的。于是我打算用<![CDATA]]>来解决,无奈,这个"&" 是放在XMl的属性url中的。

我在网上搜索了一下,有热心的网友说可以用&#38;代替,于是我把"&"替换成了"&#38;",问题终于解决了,差点今天晚上没有办法睡觉啊。。

现在把HTML中常用的特殊字符表贴出来。

部份HTML转码

SYMBOL CODE ENTITY NAME
&#8482;
&euro;
Space &#32; &nbsp;
! &#33;
" &#34; &quot;
# &#35;
$ &#36;
% &#37;
& &#38; &amp;
' &#39;
( &#40;
) &#41;
* &#42;
+ &#43;
, &#44;
- &#45;
. &#46;
/ &#47;
0 &#48;
1 &#49;
2 &#50;
3 &#51;
4 &#52;
5 &#53;
6 &#54;
7 &#55;
8 &#56;
9 &#57;
: &#58;
[ &#91;
\ &#92;
] &#93;
^ &#94;
_ &#95;
` &#96;
{ &#123;
| &#124;
} &#125;
~ &#126;
¡ &#161; &iexcl;
¢ &#162; &cent;
£ &#163; &pound;
¤ &#164; &curren;
¥ &#165; &yen;
¦ &#166; &brvbar;
§ &#167; &sect;
¨ &#168; &uml;
© &#169; &copy;
ª &#170; &ordf;
« &#171;
¬ &#172; &not;
&#173; &shy;
® &#174; &reg;
¯ &#175; &macr;
° &#176; &deg;
± &#177; &plusmn;
² &#178; &sup2;
³ &#179; &sup3;
@H_390_502@; @H_390_502@&#59; @H_390_502@
SYMBOL CODE ENTITY NAME
< &#60; &lt;
= &#61;
> &#62; &gt;
? &#63;
@ &#64;
A &#65;
B &#66;
C &#67;
D &#68;
E &#69;
F &#70;
G &#71;
H &#72;
I &#73;
J &#74;
K &#75;
L &#76;
M &#77;
N &#78;
O &#79;
P &#80;
Q &#81;
R &#82;
S &#83;
T &#84;
U &#85;
V &#86;
W &#87;
X &#88;
Y &#89;
Z &#90;
a &#97;
b &#98;
c &#99;
d &#100;
e &#101;
f &#102;
g &#103;
h &#104;
i &#105;
j &#106;
k &#107;
l &#108;
m &#109;
n &#110;
o &#111;
p &#112;
q &#113;
r &#114;
s &#115;
t &#116;
u &#117;
v &#118;
w &#119;
x &#120;
y &#121;
z &#122;
原文链接:https://www.f2er.com/xml/299529.html

猜你在找的XML相关文章