0

I am trying to grab an img url but I keep getting stuck with the inner or outterhtml which is still kinda a mess. I am grabbing it with

HtmlNode htmltable = mydoc.DocumentNode.SelectSingleNode("(//*[@id='mw-content-text']/figure[1]/a/img)");

that still leaves me with <img alt =\"blah\"src=\"http://imageIwant.png\">" string is there an easy way to parse out all the extra and just have http://imageIwant.png

2

1 Answer 1

1

The HtmlNode has attributes namevalue collection which you can cycle through and look for src attribute and that will give the url of the image.

htmltable.Attributes['src'] will give the image url.

3
  • this question has been answered elsewhere Jun 24, 2014 at 18:27
  • yup, that was it I am using string htmlurl = htmltable.Attributes[1].Value;
    – TankCR
    Jun 24, 2014 at 18:34
  • @RachelGallen, I hope the fact that the question was answered elsewhere wasn't the basis for a downvote.
    – LarsH
    Jun 24, 2014 at 20:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.