【发布时间】:2014-02-04 08:16:30
【问题描述】:
我有一个 html 页面,我正在使用 html 敏捷性进行处理,这是页面的结构。 div 类是“show1”、“show2”等等。是的,名称保持不变。如何加载名称为 song_html 的所有 div 或带有“show”+number 的类,然后是每个内部 div 的值(歌曲信息、标题和超链接值。)
<div id="container">
<div class="show1" id="song_html">
<div class="left">
Info1
</div>
<div id="right_song">
<div style="font-size:15px;">
<b>Song Title</b>
</div>
<div style="float:left;">
<a style="color:green;" target="_blank" rel="nofollow"
href="linktofile">Download</a>
</div>
</div>
</div>
<div class="show2" id="song_html">
<div class="left">
Info2
</div>
<div id="right_song">
<div style="font-size:15px;">
<b>Song Title 2</b>
</div>
<div style="float:left;">
<a style="color:green;" target="_blank" rel="nofollow"
href="linktofile">Download</a>
</div>
</div>
</div>
</div>
我们将不胜感激。这就是我到目前为止所做的。
var nodes = doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("show"));
foreach (HtmlNode node in nodes)
{
}
问候 督导员
【问题讨论】:
-
您有多个带有
id="right_song"和id="song_html"的div,对吗?
标签: html c#-4.0 html-agility-pack