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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:39:47+00:00 2026-06-17T12:39:47+00:00

I have an XML and I want to get the Xml Node values dynamically.

  • 0

I have an XML and I want to get the Xml Node values dynamically. I want to Pass the Node Name and the in return the function or SP should return me the value of that Node.

<ClassificationTypeEntity>

        <LTABLE_ID>3170</LTABLE_ID>

        <LTABLE_CODE>script Code</LTABLE_CODE>

        <LTABLE_DESC>alert(''hello'')</LTABLE_DESC>

        <ACTIVE_YES_NO>1</ACTIVE_YES_NO>enter code here

        <PRIVATE_FILING>0</PRIVATE_FILING>

        <RETENTION_CODE /><RETENTION_TITLE />

        <LTABLE_ID_P>0</LTABLE_ID_P>

</ClassificationTypeEntity>;

For Example, In the above xml, when I want the value of LTABLE_CODE Node, I will pass the same and the result should I get is

script code

Same for LTABLE_DESC the result should be alert(”hello”)

However I can write the 2 Xpath query for both but in case my schema gets changed (more properties added or removed) then I will have to change my SP also.

Thanks,
Mohit Jain

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

    Thanks for your replies.

    I have found the solution:

    declare @xmlData xml, @NodeName VarChar(500), @nodeValue VarChar(500)
    
    Set @NodeName = 'LTABLE_CODE';
    
    --Set @NodeName = 'LTABLE_DESC';
    
    set @xmlData = 
    
     '<ClassificationTypeEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
       <LTABLE_ID>3170</LTABLE_ID>
    
       <LTABLE_CODE>&lt;script&gt;al</LTABLE_CODE>
    
       <LTABLE_DESC>&lt;script&gt;alert(''hello'')&lt;/script&gt;</LTABLE_DESC>
    
       <ACTIVE_YES_NO>1</ACTIVE_YES_NO>
    
       <PRIVATE_FILING>0</PRIVATE_FILING>
    
       <RETENTION_CODE /><RETENTION_TITLE />
    
       <LTABLE_ID_P>0</LTABLE_ID_P>
    
    </ClassificationTypeEntity>'
    
    SET @nodeValue = @xmlData.value('(/ClassificationTypeEntity/*[local-name()=sql:variable("@NodeName")])[1]','nvarchar(max)')
    
    SELECT @nodeValue
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following xml and I want to fetch the value of node which
I have this xml file and I want to get some values with Xpath.
Suppose I have this XML document... <root> <str name=My node's attribute>My string's value</str> </root>
I want to get the node values of the xml string in a visual
I have one problem , I want to get some data from XML file
I have XML in the following form that I want to parse with PHP
I have some XML that I want to parse using the lxml method in
I have an XML documment that I want to load for the iPhone, do
I have the following XML and I want to process it so that I
I have an xml file that I want to configure using a bash script.

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.