May I have some help to get a value from an HTML document?
Here is the document contents:
<html>
<head>
<style>body, table, input, select, textarea, button { font: normal 1em Verdana, Sans-Serif; } body { font-size: 0.8em; } a { color:#336600; } b { color:#003300; }.header {font-family: verdana; font-size: 15px; color:#003300; font-weight:bold;}.back {background-color:#DBF0DB;}.back2 {background-color:#009933;}
</style>
</head>
<body>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td colspan="2" class="header">#827216</td>
</tr>
</table>
<body>
</html>
I am wanting to retrieve the #827216 value.
Here is the code I am working with, that does not work correctly:
hdoc.LoadHtml(FileContents);
var xID = hdoc.DocumentNode.SelectNodes("/html/body/table/tr/");
And here is the error:
Expression must evaluate to a node-set
Your HTML code is not valid XML. The body
tag is not closed. Also your XPath expression should be /html/body/table/tr/td
to get to the td
element. Also, to get one element you should use selectSingleNode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With