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 8182353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:50:16+00:00 2026-06-07T00:50:16+00:00

i have this hap code of which tries to selects sub-node from the main

  • 0

i have this hap code of which tries to selects sub-node from the main collection of nodes

Dim items As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item")

 For Each item In items
   link = item.SelectSingleNode("//link")
   title = item.SelectSingleNode("//title")
 next

the xml is

<rss version="2.0">
<channel>
    <title>title title</title>
<link>http://www.link.com</link>
<description>long decription</description>
<item>
    <title>title title</title>
    <link>http://www.link.com/</link>
    <description> description</description>
    </item>
    <item>
    <title>title title</title>
    <link>http://www.link.com/</link>
    <description> description</description>
    </item>
    <item>
    <title>title title</title>
    <link>http://www.link.com/</link>
    <description> description</description>
    </item>
</channel>
</rss>

but i don get the appropriate node title and link under item for each of the items.
where am i getting it wrong?

i could have just done

Dim links As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item/link")
Dim titles As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//channel/item/title")

but i need the link and title for each item

  • 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-07T00:50:18+00:00Added an answer on June 7, 2026 at 12:50 am

    Seems to me like a bug in HtmlAgilityPack. I had issues only retrieving the InnerText for the link element, not the others. For that one, the text was found as its sibling, not as child at least.

    Anyway, this wouldn’t be the first bug encountered in HtmlAgilityPack, so we should live with it :).

    Alternative:

    Use an XmlDocument since there’s no HTML involved here. That is an XML.

    static void Main(string[] args)
    {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(ConsoleApplication3.Properties.Settings.Default.RSS);
    
        var items = xmlDoc.SelectNodes("//channel/item");
        foreach (var item in items)
        {
            XmlNode node = (XmlNode)item;
            var link = node.SelectSingleNode("//link");
            var title = node.SelectSingleNode("//title");
    
            if (link != null)
            {
                Console.WriteLine(link.InnerText);
            }
            if (title != null)
            {
                Console.WriteLine(title.InnerText);
            }
        }
    
        Console.ReadKey();
    }
    

    Output:

    http://www.link.com

    title title

    http://www.link.com

    title title

    http://www.link.com

    title title

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which extracts data from a csv file and then reformats
I have this C# code which converts a dataset to xlsx. Is there a
I have this code, which I found on here, which finds the color of
have this code: void set(list<Person*>* listP){ Person timmy = Person(10); listP->push_back(&timmy); } int main()
I have this SQL code: SELECT t1.offname, t2.offname, t3.offname, t4.offname, t5.offname, t6.offname, t7.offname FROM
I have this form, in which i need to populate a combo box with
Have this dictionay retrieving values from DataTable: Dictionary<string,string> meta= ds.Tables[1].Select(key<>'format').AsEnumerable().ToDictionary(k=>k.Field<string>(0),v=>v.Field<string>(1)); How would I apply
I have this code to send variables to a datagrid on another page protected
Have have this line of code in my form when I create a new
I have this piece of code in one of my .jade files: each item

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.