C# - Using HTMLAgilityPack to convert a Node to String

c# dom html-agility-pack selectsinglenode

Question

I'm attempting to turn the inside text of a certain span element into a string.

<span id="course-text">ELEC1700/ELEC1700 2012 S1: Computer Engineering 1</span>

ELEC1700/ELEC1700 2012 S1: Computer Engineering 1 would thereafter be added to the aforementioned.

I've tried a few different combos using innerText and getAttributes, but I'm unable to make it work.

string name;

WebClient client = new WebClient();

HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

htmlDoc.Load(new System.IO.StringReader(client.DownloadString(urlTxtBx.Text)));

name = htmlDoc.DocumentNode.SelectSingleNode("//span[@id='course-text']").InnerText;
1
1
6/8/2012 11:32:32 AM

Accepted Answer

I was lacking the customer. using the urlTxtBx.downloadString. Text's

Code above now works correctly:)

0
6/8/2012 11:36:35 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow