0
<div class="colmask">
  <h1 class="continent_header"><a name="US"></a>US</h1>
    <div class="colmid">
        <div class="colin">
          <div class="colleft">
          .......
          ....... 
          </div>
         </div>
    </div>
   </h1>
 </div>

How can I get the inner html of tag using Regular Expression ? It means the result will be

  <h1 class="continent_header"><a name="US"></a>US</h1>
    <div class="colmid">
        <div class="colin">
          <div class="colleft">
          .......
          ....... 
          </div>
         </div>
    </div>
   </h1>
Alan Moore
  • 73,866
  • 12
  • 100
  • 156
  • 4
    Don't parse HTML with Regular expressions, use [HTMLAgilityPack](http://htmlagilitypack.codeplex.com/) instead – Shai Jul 17 '12 at 10:29
  • 1
    http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – L.B Jul 17 '12 at 10:30
  • http://stackoverflow.com/questions/9843778/regex-catching-multiline-script-tag-inside-html – Alberto De Caro Jul 17 '12 at 10:32

1 Answers1

1

Please don't use regular expressions to parse HTML, instead use HTML Agility Pack.

You can achieve what you want via:

string elementText = doc.GetElementbyId("ELEMENTID").InnerHtml;
Community
  • 1
  • 1
dtsg
  • 4,408
  • 4
  • 30
  • 40