Selectors allows you to select an HTML node from the HTMLDocument. Methods
name |
Description |
SelectNodes () |
Selects a list of nodes matching the XPath expression. |
selectSingleNode (String) |
Selects the XmlNode that matches the XPath expression. |
SelectNodes Method
Select the list of nodes that match the HtmlAgilityPack.HtmlNode.XPath expression. Parameters:
An xpath:xpath expression. return:
A htmlagilitypack.htmlnodecollection containing a collection of nodes that match the HtmlAgilityPack.HtmlNode.XPath query, or null if no nodes match the XPath expression.
The following example uses the SelectNodes method to select the first node that matches an XPath expression.
var htmldoc = new HTMLDocument ();
htmldoc.loadhtml (HTML);
String name = Htmldoc.documentnode
. SelectNodes ("//td/input")
. A ()
. attributes["Value"]. Value;
The following example selects all nodes that match an XPath expression.
var htmldoc = new HTMLDocument ();
htmldoc.loadhtml (HTML);
var htmlnodes = htmlDoc.DocumentNode.SelectNodes ("//td/input");