c# - How to retrieve the value from HTML -
i'm trying extract value html string in console application.
this msdn explains want, get html element value
in console application, function looks like
public void mymethod() { var myvalue = getvaluefromhtml("<a href=\"#\">my link</a>"); } internal string getvaluefromhtml(code) { //mycode //returns link }
i can using string manipulation, splitting on first >
, on new values first '<'.
i guess try , convert xdocument (although expections thrown illegal characters workable still) overall seems little overkill? tried using xelement complains since have <
tags
i'm asuming use htmlelement.getvalue() achieve same thing don't know how when i'm not working array/list?
i suggest use htmlagilitypack (available nuget):
string html = "<a href=\"#\">my link</a>"; var node = htmlnode.createnode(html); string value = node.innerhtml; // "my link"
Comments
Post a Comment