tags:

views:

31

answers:

1

Hi Experts,

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:[email protected]">[email protected]</a></p> <p><em>"Text goes <font 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...

+1  A: 

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

Jader Dias
Yes, and that library is http://htmlagilitypack.codeplex.com/ :)
Kirk Woll
@Kirk I just finished editing my answer when I saw your comment
Jader Dias
Do I really need to use HTMLAGILITYPack bcoz my content shows in only one place and the max character would be 500.
Deepu
@Either do you do it manually without programming, or you will have to parse the HTML. If the HTML is XML compliant (ie. XHTML) maybe you can also use a XML parser. If don't want to use either you'll have to write your own.
Jader Dias