Search code examples
c#.netwpfregexwindows-phone-8

Get string from html with Regex


I have HTML with this code inside:

    <div id="div_space">
    <div id="div" class="SCREENONLY" itemprop="description">Baby you<br />
    abcdefghijklmnop123456789</div><div id="song" class="PRINTONLY">blabla</div>

And i want to parse abcdefghijklmnop123456789 from the html with Regex:

string str = "<div id=ֿ\"div_spaceֿ\">(.*?)</div>"
Regex regex = new Regex(str);
Match match = regex.Match(html);

And Match is always empty, any idea what could be the problem?


Solution

  • AS Slaks commented you can get help of library like Html Agile pack to do this task

    var dives = from div in htmlDoc.DocumentNode.Descendants("div")
               where div.Id == "div_space" 
               select div;