Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:58:08+00:00 2026-06-13T18:58:08+00:00

I am using HTML Agility to get all the images since image dont always

  • 0

I am using HTML Agility to get all the images since image dont always have absolute path i am trying to do following. But line marked below in the code generates error

Cannot implicitly convert type ‘System.Uri’ to ‘System.Collections.Generic.List’

I am not sure how to fix this i tried so many option but keep on getting one or the other error

List<String> imgList = (from x in doc.DocumentNode.Descendants("img")
                      where x.Attributes["src"] != null
                      select x.Attributes["src"].Value.ToLower()).ToList<String>();

List<String> AbsoluteImageUrl = new List<String>();

foreach (String element in imgList)
{
    AbsoluteImageUrl = new Uri(baseUrl, element); //GIVES ERROR
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:58:09+00:00Added an answer on June 13, 2026 at 6:58 pm

    The compiler generates an error, because the type of AbsoluteImageUrl is not compatible with the type of your Uri. If you need to add the Uri to a string list, you should obtain its underlying string (e.g. Uri.AbsolutePath). In this case, the code would look like this:

    AbsoluteImageUrl.Add(new Uri(baseUrl, element).AbsolutePath);
    

    On the other hand, if you need an Uri list instead, keep your original code and change the type of AbsoluteImageUrl:

    List<Uri> AbsoluteImageUrl = new List<Uri>();
    

    Once this is done, you should use AbsoluteImageUrl.Add in the loop to add the Uri to the list.


    Regarding the discussion in comments about difference between Uri.ToString() and Uri.AbsolutePath, they have a different definitions per the official MSDN, so it depends on the OP’s requirements which he/she should use. The source code of Uri.ToString, on a side note, is as follows, so it is fundamentally different from AbsolutePath:

    [SecurityPermission(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)]
    public override string ToString()
    {
        if (this.m_Syntax == null)
        {
            if (this.m_iriParsing && this.InFact(Flags.HasUnicode))
            {
                return this.m_String;
            }
            return this.OriginalString;
        }
        this.EnsureUriInfo();
        if (this.m_Info.String == null)
        {
            if (this.Syntax.IsSimple)
            {
                this.m_Info.String = this.GetComponentsHelper(UriComponents.AbsoluteUri, (UriFormat) 0x7fff);
            }
            else
            {
                this.m_Info.String = this.GetParts(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped);
            }
        }
        return this.m_Info.String;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML that I'm trying to parse using the HTML Agility
I'm trying to get google search results using HTML Agility Pack, but I am
Using the HTML Agility Pack , how can I remove all HTML attributes, elements,
I'm using the HTML agility pack to scrape a website. I'm looking though all
I am trying to stop XSS attack so I am using html agility pack
I'm trying to highlight a text in the html string by using Html Agility
How do I get all the divs ids on a html page using Html
I want to extract Title, Description & images from URL using HTML Agility utility
I am using HTML Agility Pack to parse html content. I am using parsing
I am using html agility pack to parse html tabular information . Now there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.