我正在构建一个C#程序,该程序在一个网站上进行,并且需要一个span#id。
这是我的代码:
var web = new HtmlWeb();
var doc = web.Load(url);
System.Threading.Thread.Sleep(21000);
string adress = doc.DocumentNode
.SelectSingleNode("//td/span#myId")
.Attributes["value"].Value;
我总是得到这个错误“system.Xml.XPath.XpathException”:
谢谢
假设您的HTML看起来像这样:
<body>
<table>
<tr>
<td><span id="testedAddress">Some text here</span></td>
</tr>
</table>
</body>
然后你想要的XPath是//td/span[@id='testedAddress']