渲染或转换的HTML“格式”文本(.NET) [英] Render or convert Html to 'formatted' Text (.NET)
问题描述
我是从另一个测试/ bug跟踪工具导入一些数据TFS,我想将其转换的描述,这是简单的HTML,所以纯字符串,其中的HTML'布局'被保留。
I'm importing some data from another test/bug tracking tool into tfs, and I would like to convert it's description, which is in simple HTML, so a plain string, where the 'layout' of the HTML is preserved.
例如:
<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实体翻译等不会成为纯文本:
Would become plain text with newlines inserted and HTML-entities translated like:
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>
好像我重新发明的东西(浏览器?)。所以,如果有人在我之前做过这个我不知道。使用谷歌我找不到它。
I can currently replace some tags with newlines using a regex and strip the rest, but replacing the HTML-entities and stuff like <ol>
and <ul>
seemed like I'm re-inventing something (browser?). So I was wondering if someone has done this before me. I can't find it using Google.
推荐答案
在最后,一旦我得到更舒适的TFS,我的定制工作项目类型包括一个新的HTML场,和刚才复制的内容到该字段。
In the end, once I got more comfortable with TFS, I customized the work item type to include a new HTML Field, and just copied the contents into that field.
这解决方案是好多了,因为我们现在可以看到的预期格式域。
This solution was so much better, because we could now see the intended formatting of the field.
这篇关于渲染或转换的HTML“格式”文本(.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!