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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:58:23+00:00 2026-05-28T05:58:23+00:00

More of reflection that a problem . Im creating a stored procedure that takes

  • 0

More of reflection that a problem . Im creating a stored procedure that takes xml as an input parameter and having some issues when querying the data.

This is one of the queries

DECLARE @xVar XML
SET @xVar = 
  '<?xml version="1.0"?>
<Workflow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://ait.com/workflow/">
  <Users>
    <User ObjectId="1232">
      <UserId>123</UserId>
    </User>
    <User ObjectId="1232">
      <UserId>124</UserId>
    </User>
  </Users>
</Workflow>';


WITH XMLNAMESPACES(DEFAULT 'http://ait.com/workflow/') 
SELECT  [UserId] = reportdata.item.value('UserId[1]', 'varchar(36)')

FROM   @xVar.nodes('//Workflow/Users/User') AS reportdata(item)  

This just returns the userid’s in the xml document . If i take a close look at the last part of the select statement

FROM   @xVar.nodes('//Workflow/Users/User') AS reportdata(item)  

It works and seems logical , start from the root and specify path, what is strange to me is that this also works

FROM   @xVar.nodes('//Users/User') AS reportdata(item)  

and even stranger that this works

FROM   @xVar.nodes('//User') AS reportdata(item)  

Probably missed some page in the XML Book for dummies, could someone enlighten me please

  • 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-28T05:58:23+00:00Added an answer on May 28, 2026 at 5:58 am

    The double // means that it will give you all descendant nodes that match the expression.

    This //Workflow/Users/User does not mean “start from the root”. An expression that matches from the root looks like this /Workflow/Users/User.

    So //User will give you all descendant user nodes regardless of where they are.

    Try this:

    declare @XML xml = 
    '<root>
      <user>1</user>
      <user>2</user>
      <child>
        <user>3</user>
      </child>
    </root>'
    
    select T.N.value('.',  'int') as Value
    from @XML.nodes('//user') as T(N)
    
    select T.N.value('.',  'int') as Value
    from @XML.nodes('/user') as T(N)
    
    select T.N.value('.',  'int') as Value
    from @XML.nodes('/root/user') as T(N)
    

    Result:

    Value
    -----------
    1
    2
    3
    
    (3 row(s) affected)
    
    Value
    -----------
    
    (0 row(s) affected)
    
    Value
    -----------
    1
    2
    
    (2 row(s) affected)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to test that setting a certain property (or more generally, executing some
What is the origin of the term reflection? It seems more like introspection. Why
The problem I have is that I need to do about 40+ conversions to
What is the best way to implement an interface that combines some instances of
Problem description: Mathematica use \:nnnn as the syntax for unicode input. E.g., if we
I'm currently refactoring some code on a project that is wrapping up, and I
I'm just discovering LINQ and finding it great. One problem thoush is that I
I am having a problem using HttpWebRequest against a HTTP daemon on an embedded
I'm having a problem working in SharpDevelop using NHibernate and SQLite. I've seen people
A common problem in any language is to assert that parameters sent in to

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.