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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:15:03+00:00 2026-06-12T07:15:03+00:00

I know it’s a bizarre question! The requirement is due to the existing code

  • 0

I know it’s a bizarre question!

The requirement is due to the existing code which expects the result of the XPath query to be a single node. Unfortunately, we are unable to make code changes at this time due to factors outside of our control (unless no workaround exists, which would probably mean that we would have to delay our release).

In my case, the XPath currently returns an integer value (count):

count(/someNode/node)

The code uses XPathNavigator.SelectSingleNode() method, which, of course, fails because the result is not a node.

Instead, I need the XPath to return a node, albeit a fake one. Is it possible? Note that because .NET is used, the XPath would have to be 1.0 (not 2.0).

P.S. And, yes, we’ll look into refactoring the code in question ASAP!

  • 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-12T07:15:04+00:00Added an answer on June 12, 2026 at 7:15 am

    If you need your XPath expression to return a node whose text content is equal to the value of count(/someNode/node), you could do it like this:

    "(//text() | //*/@*)[. = count(/someNode/node)]"
    

    That might be grossly inefficient, depending on what your input document is like; and it might very well fail if there is no text node in the input document that contains the right number. However in some circumstances it could do the trick, and might help you avoid delaying your release.

    For example, if your input XML is small, and the range of possible values for the count(...) is limited, and if you are able to make changes to the XML, then you could include extra text or attribute nodes in your input XML to make sure the needed numbers are available.

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

Sidebar

Related Questions

I know that this sort of question has been asked here before, but still
i know this is a stupid question but i d'ont know how to do
I know this is a stupid question, but I've looked for 45 mins now
I know regex and substrings is a common question on here but i can
I know this is a very simple question for you experts,but please forgive me.Im
I know this is an oft asked question, but I've tried some of the
Know of a way to mock %[]? I'm writing tests for code that makes
I know this is kind of easy question but i cant seem to find
I know we can do correlated subqueries and join. But which one is faster?
I know the title is not great but I think the code will come

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.