html - C# - Extract speciifc div class text using HTMLAgility -
i have code in c# want extract below value (the text "i want text" in html code below). have reformat html code make readable.
<div class="paste-copy-url" style="margin:0 0 0 0;"> <h4>my stats:</h4> <div class="line"> <div class="wrap-input"> <input onclick="this.select();" value="i want text" readonly="readonly"> </div> </div> <h4>website link:</h4> <div class="line"> <div class="wrap-input"><input onclick="this.select();" value="some value" readonly="readonly"> </div> </div> </div>
the code tried (it giving me text : "website link:"):
var myvaluetoextract = htmldocument.documentnode.selectsinglenode("//div[@class='paste-copy-url']");
what doing wrong? can use approach element (there 1 instance of div class in page)?
var input = htmldocument.documentnode .selectsinglenode("//div[@class='paste-copy-url']//div[@class='wrap-input']/input"); var yourtext = input.attributes["value"].value;
Comments
Post a Comment