在C#中修改HTML字符串? [英] Modifying HTML strings in C#?
问题描述
在我的MVC解决方案中,我有一个HTML字符串,并且希望搜索评论节点并根据其内容替换它们。
我该怎么做?
谢谢。
编辑:语言是C#。 HTML字符串例如是< div id ='id1'> blahblah< / div><! - comment1 count = '10'length ='200' - >< p>显示真实评论内容在此段落之前。< / p>
。我需要获得注释块,然后根据计数和长度属性生成真实内容。
由于复杂性HTML你应该真的使用丰富的库来帮助你。
我强烈建议 HTMLAgility ,然后您可以按照这篇文章的建议努力实现您的目标。
In my MVC solution, I have an HTML string and want to search for comment nodes and replace them based on their content.
How can I do this?
Thank you.
EDIT: The language is C#. The HTML string is e.g. "<div id='id1'>blahblah</div><!-- comment1 count='10' length='200' --><p>show real comment content before this paragraph.</p>"
. I need to get the comment block and then generate real content based on the count and length attributes.
Because of the complexity of HTML you should really use a rich library to help you.
I highly recommend HTMLAgility, you could then follow the advice from this post to work towards achieving your goal.
这篇关于在C#中修改HTML字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!