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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:12:02+00:00 2026-05-27T17:12:02+00:00

I have to gather information from a product page which does not have any

  • 0

I have to gather information from a product page which does not have any class or id. I am using htmlagilitypack and c# 4.0.

There are many tables at this product page source code. The prices table contains ” KDV” string. So i would like to get this ” KDV” string containing table. How can i do that ?

The xpath below would select all tables for example

string srxPathOfCategory = "//table";
var selectedNodes = myDoc.DocumentNode.SelectNodes(srxPathOfCategory);

The code below selects the table but starting from most outer table. I need to select most inner table which contains that given string

//table[contains(., ' KDV')]

c# , xpath , htmlagilitypack

  • 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-05-27T17:12:03+00:00Added an answer on May 27, 2026 at 5:12 pm

    The code below selects the table but starting from most outer table. I
    need to select most inner table which contains that given string

    Use:

    //table
        [not(descendant::table) 
       and 
         .//text()[contains(., ' KDV')]
        ]
    

    This selects any table in the XML document that doesn’t have a table descendant, and that has a text node descendant that contains the string " KDV" .

    In general the above expression could select many such table elements.

    If you want only one of them selected (say the first), use this XPath expression — do notice the brackets:

       (//table
            [not(descendant::table) 
           and 
             .//text()[contains(., ' KDV')]
            ]
        )[1]
    

    Remember: If you want to select the first someName element in the document, using this (as in the currently accepted answer) is wrong:

    //someName[1]
    

    This is the second most FAQ in XPath (after the one how to select elements with unprefixed names in an XML document with a default namespace).

    The expression above actually selects any someName element in the document, that is the first child of its parent — try it.

    The reason for this unintuitive behavior is because the XPath [] operator has a higher precedence (priority) that the // pseudo-operator.

    The correct expression that really selects only the first someName element (in any XML document), if such exists is:

    (//someName)[1]
    

    Here the brackets are used to explicitly override the default XPath operator precedence.

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

Sidebar

Related Questions

Is there any way I could gather specific information from users who use my
I have an iPhone application which has some methods to gather information from the
I have about 4 tables from which I like to gather information and then
I have some sql that gathers product information. It also retrieves images from joined
I have a products page where 8 product images are in a list which
Returning information from webservice. I have made a class for the return object. But
I have created a DLL that will gather information from the AssemblyInfo.cs. In the
I have a situation where I have to gather information from a webpage. I
In one of my project i have to gather full system information (hardware and
have written this little class, which generates a UUID every time an object of

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.