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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:28:16+00:00 2026-06-13T12:28:16+00:00

I have XML in the following format: <filters> <filter name=filterByOperatingSystem> <parameters operatingSystem=Windows /> </filter>

  • 0

I have XML in the following format:

<filters>
  <filter name="filterByOperatingSystem">
   <parameters operatingSystem="Windows" />
  </filter>
  <filter name="filterBySoftware">
   <parameter software="Office" />
  </filter>
</filters>

stored in @XML.

What I would like to do is loop though each of the filters so that I can do some processing.

My thought was that I could grab each filter name along with the parameters element in a cursor, but the closest I can get so far is:

DECLARE crsDTO cursor static forward_only read_only for 
SELECT  
  tab.col.value('@name','NVARCHAR(64)')
FROM
  @XML.nodes('//filter') tab(col)

I tried the following query to see if I could get the parameter xml out:

DECLARE crsDTO cursor static forward_only read_only for 
SELECT  
  tab.col.value('@name','NVARCHAR(64)'),
  tab.col.value('parameter[1]' 'XML')
FROM
  @XML.nodes('//filter') tab(col)

But I got the error:

The datatype XML used in the value type is invalid

Because my filters can have different attributes I do not want to attempt to grab the attributes directly with the first query (my thought was to do the cursor, then depending on the filter name, I could get the specific parameters from the node), but without being able to get the xml node out, i’m not sure how to go about doing this.

Any suggestions as to how I could go about resolving this?

  • 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-13T12:28:17+00:00Added an answer on June 13, 2026 at 12:28 pm

    Do you need this?

    DECLARE @XML xml = '<filters>
      <filter name="filterByOperatingSystem">
       <parameters operatingSystem="Windows" />
      </filter>
      <filter name="filterBySoftware">
       <parameter software="Office" />
      </filter>
    </filters>'
    
    SELECT  
      tab.col.value('@name','NVARCHAR(64)') as name,
      tab.col.query('./*') as parameters
    FROM
      @XML.nodes('//filter') tab(col)
    

    if it’s possible that filter has other child element types you might want to change

      tab.col.query('./*') as parameters
    

    to

      tab.col.query('./parameters') as parameters
    

    or

      tab.col.query('./parameter') as parameters
    

    what ever the right name is.

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

Sidebar

Related Questions

I have XML in the following format: <Products> <Product name=MyProduct1> <Components> <Component name=MyComponent1> <Teams>
I have some XML in the following format: <ObjectData> <ModelName>MODEL_123</ModelName> <ObjectName>OBJECT_A</ObjectName> <Values> <KeyValuePair> <Key>NAME</Key>
I have an XML file in the following format: <doc> <id name=X> <type name=A>
I have an XML File with the following format: <containers> <container> <item> item name
I have two XML documens with the following format: First document: <person> <name>David</name> </person>
I have XML in the following format which I want to reformat: <blocks> <!--
I have the following xml format that i want to bind it through a
I have an xml file in the following format: <food> <desert> cake <desert> </food>
I have some (malformed DITA) XML in the following format: <dl> <dlentry><dt>BLARG</dt> <dd>BLARG Definition</dd>
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234

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.