2016-06-14 18 views
0

こんにちは、これは本当に面白そうに見えますが、これがうまくいかないように見えます。C#HTMLAgility単一ノードxpathを選択

何が間違っていますか?各ウェルHREFを選択しようとしていますが、それはそれだけで同じものを選択するたびに行いません。

/shows/1329/fear-the-walking-dead/ 

それは選択する必要がある場合:

/ep/149658/britains-busiest-airport-heathrow-series-2-1of3-720p-x264-hdtv/ 
/ep/149657/britains-busiest-airport-heathrow-series-2-2of3-720p-x264-hdtv/ 

など

をなぜさforeachを使用して同じものを選択するだけで、別のノードがコードをヒアリングします。

HtmlDocument doc = new HtmlDocument(); 
    doc.LoadHtml("<table align = center border = 0 cellpadding = 0 cellspacing = 0 class=forum_header_border width = 950 ><tr>< td class=section_post_header colspan = 12 >< h1 style=display:inline>EZTV Series Torrents</h1>-<h2 style = display:inline><i>Watch & Download TV Series on EZTV</i></h2><tr><td class=forum_thread_header width = 35 title=\"Show Information\">Info<td class=forum_thread_header style=text-align:left;padding-left:10px>Episode Name<td class=forum_thread_header>Downloads<td class=forum_thread_header>Size<td class=forum_thread_header>Released<td class=forum_thread_header_end>Forum<tr class=forum_space_border><td class=header_date colspan=6>Added on: <b>23, August, 2015</b><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/1329/fear-the-walking-dead/ title=\"Fear the Walking Dead Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about Fear the Walking Dead\"></a><a href=http://www.tvmaze.com/episodes/185233/fear-the-walking-dead-1x01-pilot title=\"More info about Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv] at tvmaze.com\"onclick='return trackOutboundLink(\"http://www.tvmaze.com/episodes/185233/fear-the-walking-dead-1x01-pilot\"),!1'target=_blank><img alt=TVmaze border=0 src=/images/tvmaze-16x16.png height=16 width=16></a><td class=forum_thread_post><a href=/ep/149661/fear-the-walking-dead-s01e01-hdtv-x264-killers/ title=\"Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv] (472.60 MB)\"class=epinfo alt=\"Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv] (472.60 MB)\">Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:701bfe400e248707ac3fe94dce46bed49baedea2&dn=Fear.The.Walking.Dead.S01E01.HDTV.x264-KILLERS.mp4%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969\"title=\"Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv] (472.60 MB) Magnet Link\"rel=nofollow class=magnet></a> <a href=https://zoink.ch/torrent/Fear.The.Walking.Dead.S01E01.HDTV.x264-KILLERS.mp4[eztv].torrent title=\"Fear The Walking Dead S01E01 HDTV x264-KILLERS Torrent: Download Mirror #1\"rel=nofollow class=download_1></a><td class=forum_thread_post align=center>472.60 MB<td class=forum_thread_post align=center>9 mo<td class=forum_thread_post_end align=center><a href=/forum/discuss/149661/ title=\"Discuss about Fear The Walking Dead S01E01 HDTV x264-KILLERS [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a><tr class=forum_space_border><td class=header_date colspan=6>Added on: <b>16, May, 2016</b><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/1329/fear-the-walking-dead/ title=\"Fear the Walking Dead Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about Fear the Walking Dead\"></a><a href=http://www.tvmaze.com/episodes/664693/fear-the-walking-dead-2x06-sicut-cervus title=\"More info about Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv] at tvmaze.com\"onclick='return trackOutboundLink(\"http://www.tvmaze.com/episodes/664693/fear-the-walking-dead-2x06-sicut-cervus\"),!1'target=_blank><img alt=TVmaze border=0 src=/images/tvmaze-16x16.png height=16 width=16></a><td class=forum_thread_post><a href=/ep/149660/fear-the-walking-dead-s02e06-hdtv-x264-fleet/ title=\"Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv] (291.48 MB)\"class=epinfo alt=\"Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv] (291.48 MB)\">Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:a69a1660f62c6bfea040ad479046ec9f685a6cdf&dn=Fear.the.Walking.Dead.S02E06.HDTV.x264-FLEET%5Beztv%5D.mkv%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969\"title=\"Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv] (291.48 MB) Magnet Link\"rel=nofollow class=magnet></a> <a href=https://zoink.ch/torrent/Fear.the.Walking.Dead.S02E06.HDTV.x264-FLEET[eztv].mkv.torrent title=\"Fear the Walking Dead S02E06 HDTV x264-FLEET Torrent: Download Mirror #1\"rel=nofollow class=download_1></a> <a href=\"https://zoink.ch/mirror/Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv.ag] [alt].torrent\"title=\"Fear the Walking Dead S02E06 HDTV x264-FLEET Torrent: Download Mirror #3\"rel=nofollow class=download_3></a><td class=forum_thread_post align=center>291.48 MB<td class=forum_thread_post align=center>3 weeks<td class=forum_thread_post_end align=center><a href=/forum/discuss/149660/ title=\"Discuss about Fear the Walking Dead S02E06 HDTV x264-FLEET [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a><tr class=forum_space_border><td class=header_date colspan=6>Added on: <b>10, April, 2016</b><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/1329/fear-the-walking-dead/ title=\"Fear the Walking Dead Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about Fear the Walking Dead\"></a><a href=http://www.tvmaze.com/episodes/562186/fear-the-walking-dead-2x01-monster title=\"More info about Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv] at tvmaze.com\"onclick='return trackOutboundLink(\"http://www.tvmaze.com/episodes/562186/fear-the-walking-dead-2x01-monster\"),!1'target=_blank><img alt=TVmaze border=0 src=/images/tvmaze-16x16.png height=16 width=16></a><td class=forum_thread_post><a href=/ep/149659/fear-the-walking-dead-s02e01-720p-hdtv-x264-sva/ title=\"Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv] (1.18 GB)\"class=epinfo alt=\"Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv] (1.18 GB)\">Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:98119bd8514b88f834aa8f1e5f3dbfab89b7ac4e&dn=Fear.The.Walking.Dead.S02E01.720p.HDTV.x264-SVA%5Beztv%5D.mkv%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969\"title=\"Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv] (1.18 GB) Magnet Link\"rel=nofollow class=magnet></a> <a href=https://zoink.ch/torrent/Fear.The.Walking.Dead.S02E01.720p.HDTV.x264-SVA[eztv].mkv.torrent title=\"Fear The Walking Dead S02E01 720p HDTV x264-SVA Torrent: Download Mirror #1\"rel=nofollow class=download_1></a> <a href=\"https://zoink.ch/mirror/Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv.ag] [alt].torrent\"title=\"Fear The Walking Dead S02E01 720p HDTV x264-SVA Torrent: Download Mirror #3\"rel=nofollow class=download_3></a><td class=forum_thread_post align=center>1.18 GB<td class=forum_thread_post align=center>2 mo<td class=forum_thread_post_end align=center><a href=/forum/discuss/149659/ title=\"Discuss about Fear The Walking Dead S02E01 720p HDTV x264-SVA [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a><tr class=forum_space_border><td class=header_date colspan=6>Added on: <b>14, June, 2016</b><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/187/mv-group-documentaries/ title=\"MV Group Documentaries Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about MV Group Documentaries\"></a><td class=forum_thread_post><a href=/ep/149658/britains-busiest-airport-heathrow-series-2-1of3-720p-x264-hdtv/ title=\"Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV [eztv] (959.94 MB)\"class=epinfo alt=\"Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV [eztv] (959.94 MB)\">Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:601564318faeda0f760fe7cacd346928573101ac&dn=Britains.Busiest.Airport.Heathrow.Series.2.1of3.720p.x264.HDTV%5Beztv%5D.mp4%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969\"title=\"Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV [eztv] (959.94 MB) Magnet Link\"rel=nofollow class=magnet></a> <a href=https://zoink.ch/torrent/Britains.Busiest.Airport.Heathrow.Series.2.1of3.720p.x264.HDTV[eztv].mp4.torrent title=\"Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV Torrent: Download Mirror #1\"rel=nofollow class=download_1></a><td class=forum_thread_post align=center>959.94 MB<td class=forum_thread_post align=center>46m 29s<td class=forum_thread_post_end align=center><a href=/forum/discuss/149658/ title=\"Discuss about Britains Busiest Airport Heathrow Series 2 1of3 720p x264 HDTV [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/187/mv-group-documentaries/ title=\"MV Group Documentaries Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about MV Group Documentaries\"></a><td class=forum_thread_post><a href=/ep/149657/britains-busiest-airport-heathrow-series-2-2of3-720p-x264-hdtv/ title=\"Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV [eztv] (1022.12 MB)\"class=epinfo alt=\"Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV [eztv] (1022.12 MB)\">Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:92f98f7e01e8cbc00e4bf69d50480b7601629a15&dn=Britains.Busiest.Airport.Heathrow.Series.2.2of3.720p.x264.HDTV%5Beztv%5D.mp4%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969\"title=\"Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV [eztv] (1022.12 MB) Magnet Link\"rel=nofollow class=magnet></a> <a href=https://zoink.ch/torrent/Britains.Busiest.Airport.Heathrow.Series.2.2of3.720p.x264.HDTV[eztv].mp4.torrent title=\"Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV Torrent: Download Mirror #1\"rel=nofollow class=download_1></a><td class=forum_thread_post align=center>1022.12 MB<td class=forum_thread_post align=center>46m 29s<td class=forum_thread_post_end align=center><a href=/forum/discuss/149657/ title=\"Discuss about Britains Busiest Airport Heathrow Series 2 2of3 720p x264 HDTV [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a><tr class=forum_header_border name=hover><td class=forum_thread_post width=35><a href=/shows/187/mv-group-documentaries/ title=\"MV Group Documentaries Torrent\"><img alt=Show border=0 src=/ezimg/s/1/3/show_info.png title=\"Show Description about MV Group Documentaries\"></a><td class=forum_thread_post><a href=/ep/149656/britains-busiest-airport-heathrow-series-2-3of3-720p-x264-hdtv/ title=\"Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV [eztv] (1015.86 MB)\"class=epinfo alt=\"Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV [eztv] (1015.86 MB)\">Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV [eztv]</a><td class=forum_thread_post align=center><a href=\"magnet:?xt=urn:btih:cefd247ecc034bf7121920321f8320600d1a34ba&dn=Britains+Busiest+Airport+Heathrow+Series+2+3of3+720p+x264+HDTV+%5Beztv%5D&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=http%3A%2F%2Fwww.mvgroup.org%3A2710%2Fannounce\"title=\"Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV Torrent: Magnet Link\"rel=nofollow class=magnet></a> <a href=\"https://zoink.ch/mirror/Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV [eztv.ag] [alt].torrent\"title=\"Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV Torrent: Download Mirror #3\"rel=nofollow class=download_3></a><td class=forum_thread_post align=center>1015.86 MB<td class=forum_thread_post align=center>46m 29s<td class=forum_thread_post_end align=center><a href=/forum/discuss/149656/ title=\"Discuss about Britains Busiest Airport Heathrow Series 2 3of3 720p x264 HDTV [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a></tr><td class=forum_thread_post_end align=center><a href=/forum/discuss/149612/ title=\"Discuss about Reign S03E17 HDTV x264-FLEET [eztv]:\"rel=nofollow><img alt=Discuss border=0 src=/ezimg/s/1/3/chat_empty.png title=\"Discuss about this show\"height=16 width=16></a></table>"); 
    var node = doc.DocumentNode.SelectSingleNode("//table[@class='forum_header_border']"); 
    var nodes = node.SelectNodes("//td[@class='forum_thread_post']"); 

    foreach (HtmlNode tdNode in nodes) 
    { 
     HtmlNode aNode = tdNode.SelectSingleNode("//a[@href]"); 
     Console.WriteLine(aNode.Attributes["href"].Value); 
    } 

    Console.ReadKey(); 

cano私は混乱しているので、修正を投稿してください。

ありがとうございました。

答えて

1

"//"式に先行する "。"現在のノード参照に関連する検索を実行するようにXML検索エンジンに指示します。

HtmlNode aNode = tdNode.SelectSingleNode(".//a[@href]"); 

Xpath examples

//著者:ドキュメント内のすべての要素ので、代わりにこの

HtmlNode aNode = tdNode.SelectSingleNode("//a[@href]"); 

は、これを行います。

.//title:現在の コンテキストの1つ以上のレベルの深さすべての要素。

+0

ありがとうございました。 – Wexo

関連する問題