strip out html

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

anybody knows how i can strip out the html from a control's innerhtml to show only the relevant text? i.e
<span id="test1" runat="server"><a href="test1.htm">abcde</a><b>blah</b></span

so that on my server side code, somehow i would get "abcde blah"?
thanks!
 
newbie said:
Hello,

anybody knows how i can strip out the html from a control's innerhtml to
show only the relevant text? i.e.
<span id="test1" runat="server"><a
href="test1.htm">abcde said:
so that on my server side code, somehow i would get "abcde blah"??
thanks!

Provided it is xhtml compliant (i.e. no unclosed tags and case sensitive),
why not read the contents of each node, with an XmlTextReader? Then
concatenate each node's value using a StringBuilder.

ms-help://MS.NETFrameworkSDK/cpref/html/frlrfSystemXmlXmlTextReaderClassctor
Topic.htm

....and see the example at bottom for how to use the XmlTextReader.

R.
 
FYI... you wouldn't get "abcde blah" you'd get "abcdeblah"
I dont think there is an auto-way to do this but just look for the > and <
and use the Substring in a recursive function

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


newbie said:
Hello,

anybody knows how i can strip out the html from a control's innerhtml to
show only the relevant text? i.e.
 
Back
Top