开发者

C# - Cutting HTML String into separate lines without breaking HTML tags

开发者 https://www.devze.com 2023-01-21 23:01 出处:网络
I have to break a HTML content string in to multiple lines... And each line should have some fixed characters, 50 or 60

I have to break a HTML content string in to multiple lines...

And each line should have some fixed characters, 50 or 60

Also I don't want to break the word..or html tags...

ex : <p>Email: <a href="mailto:someone@gmail.com">someone@gmail.com</a></p> <p><em>"Text goes <f开发者_StackOverflow社区ont color=red>Hello world</font>  Text goes here and Text goes here &nbsp Text goes here 1976."</em> </p>

How can I acheive this in C# ?

Any help would be appreciated...


I think you will need a HTML parser, and then you will have to serialize it again. Instead of creating your own parser and serializer you should look into existing libraries.

For the parser I recommend the OSS Html Agility Pack

0

精彩评论

暂无评论...
验证码 换一张
取 消