I want to remove all elements, including the ones with attributes like class
, from my string.
I already checked here, so regex is apparently not the answer: RegEx match open tags except XHTML self-contained tags
I currently already have something with regex that replaces all tags from a string (note, I'm never parsing a full HTML document if that matters) and preserves the content: Regex.Replace(s, "<[^>]*(>|$)", String.Empty)
. However, I just want the div
tags removed and preserve the content.
So I have:
<div class=""fade-content""><div><span>some content</span></div></div>
<div>some content</div>
Desired output:
<span>some content</span>
some content
I was going the regex path stil, and trying something like: <div>.*<\/div>
, but that excludes divs with attributes.
How can I remove div
elements only, using VB.NET?