Feedback

alle Tabellen aus HTML Quelltext filtern

Sprache: C#

Diese Methode gibt eine List aller Tabellen aus dem übergebenen HTML Quelltext zurück. benötigte Usings: using System.Collections.Generic; using System.Text.RegularExpressions;
/// <summary> 
/// Gets the HTML tabels. 
/// </summary> 
/// <param name="html">The HTML.</param> 
/// <returns></returns> 
private List<string> GetHtmlTabels(string html) 
{ 
    string tablePattern = "<table.*?>(.*?)</table>"; 
    MatchCollection tableMatches = Regex.Matches(html, tablePattern, RegexOptions.Singleline); 
    List<string> tableContents = new List<string>(); 
    foreach (Match match in tableMatches) 
        tableContents.Add(match.Value); 
    return tableContents; 
} 
/// <summary> 
/// Gets the HTML tabels. 
/// </summary> 
/// <param name="html">The HTML.</param> 
/// <returns></returns> 
private List<string> GetHtmlTabels(string html) 
{ 
    string tablePattern = "<table.*?>(.*?)</table>"; 
    MatchCollection tableMatches = Regex.Matches(html, tablePattern, RegexOptions.Singleline); 
    List<string> tableContents = new List<string>(); 
    foreach (Match match in tableMatches) 
        tableContents.Add(match.Value); 
    return tableContents; 
}