简体   繁体   中英

Search betwen htm tags c#

how can i get info from html tags ? i want to search in html code for a example writeby and retrun result

like in first line

<th scope="row">Written&#160;by</th>

Adachitoka get this WritenBy : Adachitoka here is my html code:

 <td colspan="2" style="text-align:center;background:#CCF; font-weight:bold;">Manga</td> </tr> <tr> <th scope="row">Written&#160;by</th> <td>Adachitoka</td> </tr> <tr> <th scope="row">Published&#160;by</th> <td><a href="/wiki/Kodansha" title="Kodansha">Kodansha</a></td> </tr> <tr> <th scope="row">English publisher</th> <td> <div style="overflow:hidden; width:100%;"> <div style="width:1.5em; float:left;"><small><sup style="font-style:normal;"><a href="/wiki/Northern_America" title="Northern America">NA</a></sup></small></div> <div style="margin-left:1.5em;"><a href="/wiki/Kodansha_Comics_USA" title="Kodansha Comics USA">Kodansha Comics USA</a></div> </div> </td> </tr> <tr> <th scope="row">Demographic</th> <td><i><a href="/wiki/Sh%C5%8Dnen_manga" title="Shōnen manga">Shōnen</a></i></td> </tr> <tr> <th scope="row">Magazine</th> <td><i><a href="/wiki/Monthly_Sh%C5%8Dnen_Magazine" title="Monthly Shōnen Magazine">Monthly Shōnen Magazine</a><br /> Monthly Shōnen Magazine +</i></td> </tr> <tr> <th scope="row">Original run</th> <td><span class="nowrap">December 6, 2010</span> – ongoing</td> </tr> <tr> <th scope="row">Volumes</th> <td>15 + 1 special <span class="noprint">(<a href="/wiki/List_of_Noragami_chapters" title="List of Noragami chapters">List of volumes</a>)</span></td> </tr> <tr> <td colspan="2" style="text-align:center;background:#CCF; font-weight:bold;">Anime television series</td> </tr> <tr> <th scope="row">Directed&#160;by</th> <td>Kotaro Tamura</td> </tr> <tr> <th scope="row">Written&#160;by</th> <td>Deko Akao</td> </tr> <tr> <th scope="row">Music&#160;by</th> <td><a href="/wiki/Taku_Iwasaki" title="Taku Iwasaki">Taku Iwasaki</a></td> </tr> <tr> <th scope="row">Studio</th> <td><a href="/wiki/Bones_(studio)" title="Bones (studio)">Bones</a></td> </tr> <tr> <th scope="row">Licensed&#160;by</th> <td> <div style="overflow:hidden; width:100%;"> <div style="width:1.7em; float:left;"><small><sup style="font-style:normal;"><a href="/wiki/Australasia" title="Australasia">AUS</a></sup></small></div> <div style="margin-left:1.5em;"><a href="/wiki/Madman_Entertainment" title="Madman Entertainment">Madman Entertainment</a></div> </div> <div style="overflow:hidden; width:100%;"> <div style="width:1.5em; float:left;"><small><sup style="font-style:normal;"><a href="/wiki/Northern_America" title="Northern America">NA</a></sup></small></div> <div style="margin-left:1.5em;"><a href="/wiki/Funimation" title="Funimation">Funimation</a></div> </div> <div style="overflow:hidden; width:100%;"> <div style="width:1.5em; float:left;"><small><sup style="font-style:normal;"><a href="/wiki/United_Kingdom" title="United Kingdom">UK</a></sup></small></div> <div style="margin-left:1.5em;"><a href="/wiki/Manga_Entertainment" title="Manga Entertainment">Manga Entertainment</a></div> </div> </td> </tr> <tr> <th scope="row">Network</th> <td><a href="/wiki/Tokyo_MX" title="Tokyo MX" class="mw-redirect">Tokyo MX</a>, <a href="/wiki/Mainichi_Broadcasting_System" title="Mainichi Broadcasting System">MBS</a>, <a href="/wiki/Nippon_BS_Broadcasting" title="Nippon BS Broadcasting">BS11</a>, <a href="/wiki/Television_Aichi_Broadcasting" title="Television Aichi Broadcasting">TVA</a></td> </tr> <tr> <th scope="row">Original run</th> <td><span class="nowrap">January 5, 2014</span> – <span class="nowrap">March 23, 2014</span></td> </tr> <tr> <th scope="row">Episodes</th> <td>12 <span class="noprint">(<a href="/wiki/List_of_Noragami_episodes#Season_1" title="List of Noragami episodes">List of episodes</a>)</span></td> </tr> <tr> <td colspan="2" style="text-align:center;background:#CCF; font-weight:bold;"><a href="/wiki/Original_animation_DVD" title="Original animation DVD" class="mw-redirect">Original animation DVD</a></td> </tr> <tr> <th scope="row">Directed&#160;by</th> <td>Kotaro Tamura</td> </tr> <tr> <th scope="row">Written&#160;by</th> <td>Deko Akao</td> </tr> <tr> <th scope="row">Music&#160;by</th> <td><a href="/wiki/Taku_Iwasaki" title="Taku Iwasaki">Taku Iwasaki</a></td> </tr> <tr> <th scope="row">Studio</th> <td><a href="/wiki/Bones_(studio)" title="Bones (studio)">Bones</a></td> </tr> <tr> <th scope="row">Released</th> <td><span class="nowrap">February 17, 2014</span> – <span class="nowrap">July 17, 2014</span></td> </tr> <tr> <th scope="row">Episodes</th> <td>2</td> </tr> <tr> 

Don't perform a string search of any kind on html. Html has nested structures and can contain encoded characters. Regex will fail or at least become too complicated. Don't treat html as XML either. Html can contain mismatched tags.

The best way is really the Html Agility Pack . It is very forgiving and can handle unclosed tags and other oddities.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM