浏览器无法识别<! - [CDATA [----]] - >

时间:2017-07-19 12:55:15

标签: html ios css formatting cdata

我正在尝试加载我从UIWebview中的EWS服务器获取的HTML,但它显示错误的格式化内容。

我正在从Objective c代码加载UIWebview中的内容:

 NSString *htmlString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]
                                                               pathForResource: @"html" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];


NSLog(@"File content : %@ ", htmlString);


[self.webView loadHTMLString:htmlString baseURL: nil];

我的Html内容如下:

<div style="padding-bottom: 20px;"></div><div><html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o=
"urn:schemas-microsoft-com:office:office" xmlns:w=
"urn:schemas-microsoft-com:office:word" xmlns:m=
"http://schemas.microsoft.com/office/2004/12/omml" xmlns=
"http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<meta name="Generator" content=
"Microsoft Word 15 (filtered medium)" />
<style>
<![CDATA[
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.Shkpostityyli17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1645814637;
        mso-list-type:hybrid;
        mso-list-template-ids:1769606838 67829761 67829763 67829765 67829761 67829763 67829765 67829761 67829763 67829765;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
]]>
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<title></title>
</head>
<body lang="FI" link="#0563C1" vlink="#954F72" xml:lang="FI">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:18.0pt"><span lang="EN-GB"
xml:lang="EN-GB">Hey test the lists</span></p>
<p class="MsoNormal" style="margin-left:18.0pt"><span lang="EN-GB"
xml:lang="EN-GB">&nbsp;</span></p>
<p class="MsoNormal" style="margin-left:18.0pt"><span lang="EN-GB"
xml:lang="EN-GB">lists are as follows:</span></p>
<p class="MsoNormal" style="margin-left:18.0pt"><span lang="EN-GB"
xml:lang="EN-GB">&nbsp;</span></p>
<p class="MsoListParagraph" style=
"text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="font-family:Symbol"><span style=
"mso-list:Ignore">·<span style=
"font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>
<![endif]><span lang="EN-GB" xml:lang="EN-GB">list 1</span></p>
<p class="MsoListParagraph" style=
"text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="font-family:Symbol"><span style=
"mso-list:Ignore">·<span style=
"font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>
<![endif]><span lang="EN-GB" xml:lang="EN-GB">list 2</span></p>
<p class="MsoListParagraph" style=
"text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="font-family:Symbol"><span style=
"mso-list:Ignore">·<span style=
"font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>
<![endif]><span lang="EN-GB" xml:lang="EN-GB">list 3</span></p>
<p class="MsoListParagraph" style=
"text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="font-family:Symbol"><span style=
"mso-list:Ignore">·<span style=
"font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>
<![endif]><span lang="EN-GB" xml:lang="EN-GB">list 4</span></p>
<p class="MsoListParagraph" style=
"text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span style="font-family:Symbol"><span style=
"mso-list:Ignore">·<span style=
"font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>
<![endif]><span lang="EN-GB" xml:lang="EN-GB">list 5</span></p>
<p class="MsoListParagraph">&nbsp;</p>
<p class="MsoListParagraph">End of list</p>
</div>
</body>
</html>
</div>

当我在任何在线HTML渲染器(例如此website)上运行此HTML代码时,它会显示包含项目符号行的以下内容:

Hey test the lists

 

lists are as follows:

 

·        list 1

·        list 2

·        list 3

·        list 4

·        list 5

 

End of list

当我在任何网络浏览器中加载相同的html时,它不显示项目符号行:这是UIWebview的屏幕截图,显示与其他网络浏览器相同的内容 enter image description here

1 个答案:

答案 0 :(得分:0)

这是因为<![CDATA[---]]>标签。如果Html包含CDATA内的内容,则浏览器会忽略它。

我只删除了标签,没有删除里面的内容。它现在运作良好。