strip out html

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!
 
R

Richard K Bethell

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.
 
C

Curt_C [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top