-3
我想獲得特定div的屬性值如何執行。如何使用HtmlAgilityPack獲取特定div的data-url值?
<div id="syllabus-stages" data-featurette="async-element" data-url="/library/aspnet-mvc-forms/stages" data-strategy="update"></div>
我想獲得特定div的屬性值如何執行。如何使用HtmlAgilityPack獲取特定div的data-url值?
<div id="syllabus-stages" data-featurette="async-element" data-url="/library/aspnet-mvc-forms/stages" data-strategy="update"></div>
假設你將使用HTML解析器HtmlAgilityPack(你必須標記你的問題):
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;
你能告訴你你嘗試過什麼? – Shekhar
@ shekhar,我只是想提取數據的價值url請幫我 – Martin
爲什麼給我負面的點? – Martin