c# - find all elements with data - attribute using html-agility-pack -


i using html-agility-pack parse html block of text. possible find list of elements attributes / attribute values ?

for example, below sample html text. using html-agility-pack how find elements has "data-glossaryid" attribute?

<p> sample text <a href="" data-glossaryid="f776eb48bd"></a> <p><img  alt="my pic" src="/~/media/images/mypic.jpg" /></p> sample text  <a  href="" data-glossaryid="5d476eb49e"></a> <p>  more sample text  </p> <span data-glossaryid="f776eb49ef"> </span> 

// html block of text parse var = @"<p> sample text <a href="""" data-glossaryid=""f776eb48bd""></a> <p><img  alt=""my pic"" src=""/~/media/images/mypic.jpg"" /></p> sample text <a  href="""" data-glossaryid=""5d476eb49e""></a> <p>  more sample text  </p> <span data-glossaryid=""f776eb49ef""> </span>";  // create htmldocument var htmldocument = new htmldocument(); htmldocument.loadhtml(a);  // elements attr data-glossaryid , prints values foreach (var item in htmldocument.documentnode.selectnodes("//*[@data-glossaryid]"))     console.writeline(item.getattributevalue("data-glossaryid", "")); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -