-1

I am building a C# program, which goes on a website and takes a span#id.

Here is my code :

        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;

And I always get this error "system.Xml.XPath.XpathException" :

error system.Xml.XPath.XpathException

Thanks

1
  • Your code is insufficient to understand your error and also, error information is not in English. Translate entire error. Mar 1, 2018 at 0:16

1 Answer 1

1

Assuming that your HTML looks something like this:

<body>
  <table>
    <tr>
      <td><span id="testedAddress">Some text here</span></td>
    </tr>
  </table>
</body>

Then the XPath you want is //td/span[@id='testedAddress']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.