1

I have the following code:

 foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a/@href[contains(., '/something/')]"))
             {
                 var content = link.OuterHtml;
                 // Then do something else
             }

content is equal to something like the following:

<a href="http://www.somelink.com">Happy Camper</a>

I would like content to equal just the URL portion of the HTML, so just this:

http://www.somelink.com

What would I need to change in my code to produce this desired result?

1 Answer 1

2

I figured it out. Just use:

var content = link.Attributes["href"].Value

Easy enough!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.