Extract and format non formatted text from string
I have a string which contains html and text.
If any of the text is not encapsulated by html tags then I want to encapsulate it in <P> tags however certain tags for example anchors and bold tags etc would need to remain within the string.
i.e the text below
Quote:
hgfkjvckvg
<h1>vhjvhj</h1>
fhvjvl <a href="">hvlvnlb</a>
cghcghkgkh
would become
Quote:
<p>hgfkjvckvg</p>
<h1>vhjvhj</h1>
<p>fhvjvl<a href="">hvlvnlb</a>
cghcghkgkh</p>
I am a little stuck how to provide this behavior. Im wondering if the HTML Aagility pack might help.
Re: Extract and format non formatted text from string
Hello,
The HTML Agility Pack is certainly a good place to start, however, it might not be able to do everything that you want.
You may have to fallback to parsing the string, perhaps with Regular Expressions.
Gary