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

  • Home
  • SEARCH
  • 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 585635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:01:24+00:00 2026-05-13T15:01:24+00:00

I have dynamic generated XML files —–Example1—– <items> <param1>aaaa</param1> <param2>bbbb</param2> <param3>cccc</param3> </items> —–Example2—– <items>

  • 0

I have dynamic generated XML files

-----Example1-----
<items>
<param1>aaaa</param1>
<param2>bbbb</param2>
<param3>cccc</param3>
</items>
-----Example2-----
<items>
<test1>dddd</test1>
<test7>eeee</test7>
<john1>ffff</john1>
<john2>ffff</john2>
</items>

I want to convert this xml files to table like this

-----SQL TABLE for Example1-----
Name     Value
param1   aaaa
param2   bbbb
param3   cccc
-----SQL TABLE for Example2-----
Name     Value
test1   dddd
test7   eeee
john1   ffff
john2   ffff

The problem
– items xml tags names are different in each xml file (like in sample)
– item numbers is different in each xml file

Anyone have any idea

Update1 Sample in C# that i have done but i need to do this in T-SQL 🙁

  public static void test()
    {

        string test = @"
        <items>
        <param1>aaaa</param1>
        <param2>bbbb</param2>
        <param3>cccc</param3>
        </items>
        ";

        XmlDocument newdoc = new XmlDocument();
        XmlNode root = newdoc.CreateElement("dataset");
        newdoc.AppendChild(root);
        XmlDocument doc = new XmlDocument();
        doc.InnerXml = test;
        XmlNodeList lst = doc.SelectNodes("//items/*"); 
        foreach (XmlNode item in lst)
        {
            Console.WriteLine(item.Name + ": " + item.InnerXml);
        }
    }

RESULT
param1: aaaa
param2: bbbb
param3: cccc

UPDATE2 partialy resolved
i need only get xml tag name

declare @foo xml
set @foo = N'
<items>
       <param1>aaaa</param1>
       <param2>bbbb</param2>
       <param3>cccc</param3>
</items>'

SELECT
'' as name,  --?? no idea how to get names param1,param2,param3
bar.value('./.','VARCHAR(14)')  as value 
FROM
@foo.nodes('/items/*') AS foo(bar)   
  • 1 1 Answer
  • 1 View
  • 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-13T15:01:25+00:00Added an answer on May 13, 2026 at 3:01 pm

    It would be relatively easy to create an XSLT transform to convert the XML data into a set of INSERT INTO statements. Then you could just execute those statements. How useful that approach would be depends on how much data and how fast you need to import it.

    You could even get the XSLT to do the CREATE TABLE DDL also, if you don’t have tables already.

    UPDATE:
    Using your code, you can use the local-name() function:

    declare @foo xml
    set @foo = N'
    <items>
           <param1>aaaa</param1>
           <param2>bbbb</param2>
           <param3>cccc</param3>
    </items>'
    
    SELECT
    bar.value('local-name(.)','VARCHAR(14)') as name,  
    bar.value('./.','VARCHAR(14)')  as value 
    FROM
    @foo.nodes('/items/*') AS foo(bar) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of pre-generated, static xml files containing soap requests. I can
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
Starting with a .csproj which defines various xml Content files. Have code generation Target
i have an ASP.net page that generates dynamic xml but the get statement of
I'm trying to have a dynamic textview based on the xml file..... Please help
I have a dynamic form that is generated based on javascript. Here's the relevant
How to generate HTML files depends on array length php I have an XML
I am using gmaps4rails and I have a set of dynamic generated markers, about
I have some PHP code that generates dynamic tables of data on the fly.
I have a code segment that generates a dynamic 3D array of random numbers

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.