P.Brian.Mackey
P.Brian.Mackey

Reputation: 44285

Grab innertext from an anchor serverside

How can I grab the <a> inner text? Are there any HTML helpers for this to work serverside with ASP.NET webforms? (this is not an MVC app)

Method()
{
   string trackingNumber = Database.GetTrackingNumber();
   ExtractText(trackingNumber);
}

string GetTrackingNumber()
{
     return "<a href=\"#\">TextINeedToExtract</a>"
}

ExtractText(string someHtml)
{
    //need good way to get innerHtml for the <a>. HTML is not well formed.
}

Update
I am trying to avoid adding more package dependencies. Can jquery be used serverside to handle this situation?

Upvotes: 0

Views: 347

Answers (1)

gandjustas
gandjustas

Reputation: 1955

HtmlAgilityPack

It's available from NuGet Repository

Upvotes: 1

Related Questions