| 

.NET C# Java Javascript Exception

2
Hallo zusammen,

ich möchte aus einem (Outlook.MailItem)oFolder.Items;, das MAil.HTMLBody auslesen wenn dieses ein ergebniss aus Regex regexObj = new Regex("<table.*</table>", RegexOptions.Singleline);

erfolgreich Zurückgibt möchte ich den Inhalt der Tabelle als DatenSatz weiterverarbeiten und in einer AccessDb abspeichern.

bis zum Regex resultString, alles bingo aber,

Was muss ich machen um den String der aus meiner Regex kommt als DS weiterzuverarbeiten?
Was habe ich übersehen Falschgemacht?

Danke für jede gut gemeinte Antwort

Olaf

string resultString = "<table
style='width:638.65pt;margin-left:34.65pt;border-collapse:collapse;mso-padding-alt:
0cm 0cm 0cm 0cm'>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>Kaufmännische-Software:</span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;background:#F2F2F2;
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<font
color=navy><span>----</span><o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>z.B.:
KHK</span><o:p></o:p></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>Kalkulations-Software:</span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;background:#F2F2F2;
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<font
color=navy><span>Tabellenkalkulation,<span
style='mso-spacerun:yes'>  </span>Officeanwendung</span><o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>z.B.:
WEKA Handwerksbüro&nbsp; x14</span><o:p></o:p></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>Datenaustausch Schnittstelle:</span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;background:#F2F2F2;
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<font
color=navy><span>----</span><o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>z.B.:
Gaeb 90</span><o:p></o:p></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>2:</span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>z.B.:
Gaeb 2000</span><o:p></o:p></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>3: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>z.B.:
Datanorm</span><o:p></o:p></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>4: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>5: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>6: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>7: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>8: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>9: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
height:18.75pt'>
<p >
face=Calibri><span>10: </span><o:p></o:p></p>
</td>
<td
style='width:278.5pt;border:solid windowtext 1.0pt;border-top:none;
background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span>&nbsp;<o:p></o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
<tr>
<td
0cm 3.5pt 0cm 3.5pt;height:15.0pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
0cm 3.5pt 0cm 3.5pt;height:15.0pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
<td
padding:0cm 3.5pt 0cm 3.5pt;height:15.0pt'>
<p ><span
style='font-size:12.0pt;font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
</td>
</tr>
</table>"
News:
05.06.2011
OlafS 210 1 6
Hast du Probleme mit dem RegEx-Ausdruck zum parsen der Werte oder mit der DataTable?
Floyd 05.06.2011
4 Antworten
1
Hab den C#-Code nur aus dem Gedächtnis geschrieben aber so sollte es funktionieren:

DataTable dt = new DataTable();

MatchCollection mc = Regex.Matches(resultString, "<tr>.*?<td.*?>(?<tdVal1>.*?)</td>.*?<td.*?>(?<tdVal2>.*?)</td>.*?<td.*?>(?<tdVal3>.*?)</td>.*?</tr>",
RegexOptions.Singleline | RegexOptions.IgnoreCase);

int i = 0;
foreach(Match m in mc){
i++;
if(i == 1){
dt.Columns.Add( "Col1" );
dt.Columns.Add( "Col2" );
dt.Columns.Add( "Col3" );
}
else{
DataRow dr = dt.NewRow();
dr["Col1"] = StripHtml( mc.Groups["tdVal1"].Value );
dr["Col2"] = StripHtml( mc.Groups["tdVal2"].Value );
dr["Col3"] = StripHtml( mc.Groups["tdVal3"].Value );
dt.Rows.Add( dr );
}
}
06.06.2011
Floyd 14,6k 3 9
0
Hallo,

das weitere verarbeiten ist mein Problem!
habe dies gefunden geht aber nicht!
System.Xml.Linq.XElement html =System.Xml.Linq.XElement.Parse(resultString) ;

var q = from th in html.Descendants("td")
select (string)th.Value;


Kannst Du helfen.

Danke
05.06.2011
OlafS 210 1 6
0
Cool Danke!

mache mich ans umsetzten
06.06.2011
OlafS 210 1 6
0
Danke Floyd!
Für die nach World

Gelöst!!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Data;

namespace ConsoleApplicationtest
{
class Program
{
static void Main(string[] args)
{
string s = "<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=852 style='width:638.65pt;margin-left:-.75pt;border-collapse:collapse;mso-yfti-tbllook: 1184;mso-padding-alt:0cm 0cm 0cm 0cm'> <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>Kaufmännische-Software:</span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;<span style='font-size:10.0pt;font-family:'Arial','sans-serif'; color:blue'>IN-FORM PROfessional</span></p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'> <p class=MsoNormal><span style='font-size:14.0pt'>z.B.: KHK</span></p> </td> </tr> <tr style='mso-yfti-irow:1;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'></td> <td width=371 nowrap valign=bottom style='width:278.5pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:2;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>Kalkulations-Software:</span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;<span style='font-size:10.0pt;font-family:'Arial','sans-serif'; color:blue'>Klaes</span></p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'> <p class=MsoNormal><span style='font-size:14.0pt'>z.B.: WEKA Handwerksbüro&nbsp; x14</span></p> </td> </tr> <tr style='mso-yfti-irow:3;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'></td> <td width=371 nowrap valign=bottom style='width:278.5pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:4;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>Datenaustausch Schnittstelle:</span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;<span style='font-size:10.0pt;font-family:'Arial','sans-serif'; color:blue'>DATEV</span></p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'> <p class=MsoNormal><span style='font-size:14.0pt'>z.B.: Gaeb 90</span></p> </td> </tr> <tr style='mso-yfti-irow:5;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>2:</span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;<span style='font-size:10.0pt;font-family:'Arial','sans-serif'; color:blue'>MAREON</span></p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'> <p class=MsoNormal><span style='font-size:14.0pt'>z.B.: Gaeb 2000</span></p> </td> </tr> <tr style='mso-yfti-irow:6;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>3: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'> <p class=MsoNormal><span style='font-size:14.0pt'>z.B.: Datanorm</span></p> </td> </tr> <tr style='mso-yfti-irow:7;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>4: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:8;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>5: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:9;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>6: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:10;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>7: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:11;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>8: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:12;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>9: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:13;height:18.75pt'> <td nowrap valign=top style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style1'> <p class=MsoNormal align=right style='text-align:right'><span style='font-size:14.0pt'>10: </span></p> </td> <td width=371 nowrap valign=bottom style='width:278.5pt;border:solid windowtext 1.0pt; border-top:none;background:#F2F2F2;padding:0cm 3.5pt 0cm 3.5pt;height:18.75pt'> <p class=MsoNormal>&nbsp;</p> </td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:18.75pt'></td> </tr> <tr style='mso-yfti-irow:14;mso-yfti-lastrow:yes;height:15.0pt'> <td nowrap valign=bottom style='padding:0cm 3.5pt 0cm 3.5pt; ' class='style2'></td> <td width=371 nowrap valign=bottom style='width:278.5pt;padding:0cm 3.5pt 0cm 3.5pt; height:15.0pt'></td> <td width=274 nowrap valign=bottom style='width:205.55pt;padding:0cm 3.5pt 0cm 3.5pt; height:15.0pt'></td> </tr></table>";

XMLStringtoDS(s);

}


private static void XMLStringtoDS(string subjectString)
{
DataTable dt = new DataTable();
dt.Columns.Add("Col1");
dt.Columns.Add("Col2");
dt.Columns.Add("Col3");

try {
Regex regexObj = new Regex("<tr.*?>.*?<td.*?>(?<tdVal1>.*?)</td>.*?<td.*?>(?<tdVal2>.*?)</td>.*?<td.*?>(?<tdVal3>.*?)</td>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline);
Match matchResults = regexObj.Match(subjectString);
while (matchResults.Success)
{
for (int i = 1; i < matchResults.Groups.Count; i++)
{


Group mc = matchResults.Groups;
if (mc.Success)
{
DataRow dr = dt.NewRow();
dr[("Col" + i.ToString())] = StripHTML(mc.Value);
dt.Rows.Add(dr);
// matched text: mc.Value
// match start: mc.Index
// match length: mc.Length
}
}
matchResults = matchResults.NextMatch();
}
}
catch (ArgumentException ex)
{
// Syntax error in the regular expression
}


}



//namespace reference
//using System.Text.RegularExpressions;

/// <summary>
/// method to strip HTML tags using Regular Expressions
/// </summary>
/// <param name="str">String to strip HTML from</param>
/// <returns></returns>
public static object StripHTML(string str)
{
//variable to hold the returned value
string strippedString;
try
{
//variable to hold our RegularExpression pattern
string pattern = "<.*?>";
//replace all HTML tags
strippedString = Regex.Replace(str, pattern, string.Empty);
}
catch
{
strippedString = string.Empty;
}
return (strippedString).Trim();
}
}
}

[/code]
06.06.2011
OlafS 210 1 6
Ne Antwort die hilfreich war sollte man positiv bewerten und die beste akzeptieren ;)
Floyd 07.06.2011

Stelle deine .net-Frage jetzt!
TOP TECHNOLOGIES CONSULTING GmbH