0

特定の属性を持つノードを選択することはできますか? 私が必要とするノードはすべて「data-rel」属性を持っています。「data-rel」属性値に関係なく、その属性を持つノードのみを選択したい。

<a href="/someurl.php" data-rel="...">

私はもう試した ...

List<HtmlAgilityPack.HtmlNode> groups = doc.DocumentNode.SelectNodes("//a[contains(@data-rel)]").Distinct().ToList();

... 無駄に。

4

1 に答える 1

2

試す//a[@data-rel]

http://www.w3schools.com/xpath/xpath_syntax.aspを参照してください。

//title[@lang]  Selects all the title elements that have an attribute named lang

参照http://www.w3.org/TR/xpath/#path-abbrev

employee[@secretary and @assistant] selects all the employee children of the context node that have both a secretary attribute and an assistant attribute
于 2013-07-20T13:40:07.860 に答える