-2

I want to get a value of an attribute of a specific div how to do it.

<div id="syllabus-stages" data-featurette="async-element" data-url="/library/aspnet-mvc-forms/stages" data-strategy="update"></div>
Martin
  • 386
  • 1
  • 5
  • 17

1 Answers1

2

Assuming you will use the HTML parser HtmlAgilityPack (you have the tag in your question):

WebClient client = new WebClient();
string downloadString = client.DownloadString("http://www.mywebsite/mypage");

HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(downloadString);
//string whatUrLookingFor = doc.GetElementbyId("syllabus-stages").InnerHtml;
string whatUrLookingFor = doc.GetElementbyId("syllabus-stages").Attributes["data-url"].Value;
Yanga
  • 2,885
  • 1
  • 29
  • 32