c# – 解析为纯文本的新段落

c# – 解析为纯文本的新段落,第1张

概述我目前正在从内部数据库中的字段中删除html标记.除了将标签转换为纯文本换行符之外,一切都顺利进行. 我想转换一下: The victory halted Spain’s 35-game unbeaten streak, handing the Spanish their first defeat since November 2006. The Americans now advan 我目前正在从内部数据库中的字段中删除HTML标记.除了将标签转换为纯文本换行符之外,一切都顺利进行.

我想转换一下:

The victory halted Spain&rsquo;s 35-game unbeaten streak,handing the Spanish their first defeat since November 2006. The Americans Now advance to the final Sunday to face the winner of Thursday&rsquo;s semifinal between South Africa and Brazil,the five-time World Cup winner. Brazil defeated the Americans,3-0,in their earlIEr meeting in this tournament.<br><br>In the final,though,the United States will be without mIDfIElder Michael Bradley,who received a red card for a harsh tackle in the 87th minute,the third such ejection for the Americans in this tournament. It was the only careless blemish on an otherwise nearly perfect evening.

在这:

The victory halted Spain’s 35-game unbeaten streak,handing the Spanish their first defeat since November 2006. The Americans Now advance to the final Sunday to face the winner of Thursday’s semifinal between South Africa and Brazil,in their earlIEr meeting in this tournament.In the final,the third such ejection for the Americans in this tournament. It was the only careless blemish on an otherwise nearly perfect evening.

我使用以下代码行将更改为新行字符:

value = value.Replace("<br>",Environment.Newline).Trim();

运行该代码后,这是我的数据库中保存的内容:

The victory halted Spain's 35-game unbeaten streak,handing the Spanish their first defeat since November 2006. The Americans Now advance to the final Sunday to face the winner of Thursday's semifinal between South Africa and Brazil,in their earlIEr meeting in this tournament.    In the final,the third such ejection for the Americans in this tournament. It was the only careless blemish on an otherwise nearly perfect evening.

如果我将解析后的文本保存到我的数据库并将其粘贴到记事本或Word中,我只得到一个而不是两个.

这是处理这个问题的正确方法吗?我使用的数据库是sql Server 2005.

解决方法 根据您的后续注释(当您调试它时),听起来正确的值至少是正确发送到数据库.

它可能不是这么简单,但值得检查…当你说“运行查询以获取值…并将其粘贴到Word”时,你用什么来进行查询?因为我知道如果您在默认的“结果到网格”视图中使用sql Server 2005 Management Studio查询某些内容,它不能正确呈现新行(我认为它只是用空格替换它们)…如果您将其切换为“结果到文本“(或者您从代码中获取数据库中的值并调试返回的值),您将获得更准确的实际值表示,并显示新行显示…

总结

以上是内存溢出为你收集整理的c# – 解析为纯文本的新段落全部内容,希望文章能够帮你解决c# – 解析为纯文本的新段落所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1247213.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存