1
我有一個Ul元素,它有3種不同類型的li兒童,我想排除他們班中這些類型的兒童中的2個。排除帶class =地圖和class =地圖按鈕li元素HTMLAgilityPack按類別排除
這裏就是我亂搞,
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load(Constants.New_York.GetOffenderPageById(""+ 41586));
var querylist3 = from list in
doc.DocumentNode.SelectNodes("//ul[@class='address label-value']")
.Cast<HtmlNode>()
from row in list.SelectNodes("not(li[@class='map']) and not(li[@class='map-button'])")
.Cast<HtmlNode>()
select new { CellText = Utilities.RemoveHtmlCharacters(row.InnerText) };
foreach (var q1 in querylist3)
Console.WriteLine(q1.CellText);
所以我一直在尋找HtmlAgilityPack SelectNodes expression to ignore an element with a certain attribute但無論哪種,我不能正確理解溶液或它不工作。
我不想創建對象實例,並使用LINQ比較...
供參考,這是HTML,
<ul class="address label-value">
<li><span class="label">Type</span><span class="value">RES (Primary)</span></li>
<li><span class="label">County</span><span class="value">Suffolk</span></li>
<li class="no-border-bottom"><span class="label">Address</span><span class="value">1010 OLD MEDFORD RD<br>FARMINGVILLE, New York 11738</span></li>
<li class="map-button"><a class="cta cta-blue cta-small" href="https://www.google.com/maps/embed/v1/place?key=AIzaSyDLQ6Qf1v0RJyudkTTEcAYsXPIewwO4F3w&zoom=17&q=1010 OLD MEDFORD RD,FARMINGVILLE,NY,11738">View on Map</a></li>
<li class="map">
<iframe src="" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" class="map-iframe"><!----></iframe>
<p><a href="../nsor/mapping-exceptions.htm">Learn about possible mapping exceptions.</a></p>
</li>
</ul>