c# – 将Html格式化或转换为“格式化”文本(.NET)
发布时间:2020-12-15 18:03:13 所属栏目:百科 来源:网络整理
导读:我从另一个测试/错误跟踪工具导入一些数据到tfs,我想转换它的描述,这是简单的 HTML,所以一个简单的字符串,其中HTML的“布局”被保留. 例如: body ol liLog on with user Acme amp; Co./li liNavigate to the details tab/li liCheck the official name/li /
我从另一个测试/错误跟踪工具导入一些数据到tfs,我想转换它的描述,这是简单的
HTML,所以一个简单的字符串,其中HTML的“布局”被保留.
例如: <body> <ol> <li>Log on with user Acme & Co.</li> <li>Navigate to the details tab</li> <li>Check the official name</li> </ol> <br> <br> Expected Result:<br> official name is filled in<br> <br> Actual Result:<br> The &-sign is not shown correctly<br> See attachement. </body> 将成为纯文本,插入换行符和HTML实体翻译如下: 1. Log on with user Acme & Co. 2. Navigate to the details tab 3. Check the official name Expected Result: official name is filled in Actual Result: The &-sign is not shown correctly See attachment 我现在可以使用正则表达式替换一些带有换行符的标签,并删除其他标签,但是替换HTML实体和诸如< ol>和< ul>好像我正在重新发明一些东西(浏览器?).所以我想知道有没有人在我之前这样做.我找不到使用Google. 解决方法
而不是正则表达式,您可以尝试将其加载到
HTML agility pack?如果是xhtml,那么xslt转换可能是一个很好的选择.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |