|
-
Jul 22nd, 2011, 10:41 AM
#1
Thread Starter
Frenzied Member
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
hgfkjvckvg
<h1>vhjvhj</h1>
fhvjvl <a href="">hvlvnlb</a>
cghcghkgkh
would become
<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.
-
Jul 22nd, 2011, 03:34 PM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|