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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:55:26+00:00 2026-05-16T17:55:26+00:00

Below is the actual xml: <?xml version=1.0 encoding=utf-8?> <employee> <Name>ABC</Name> <Dept>CS</Dept> <Designation>sse</Designation> </employee> And

  • 0

Below is the actual xml:

<?xml version="1.0" encoding="utf-8"?>
<employee>
 <Name>ABC</Name>
 <Dept>CS</Dept>
 <Designation>sse</Designation>
</employee>

And i want the output as below:

<?xml version="1.0" encoding="utf-8"?>
<employee>
 <Name>ABC</Name>
  <Age>34</Age>
 <Dept>CS</Dept>
  <Domain>Insurance</Domain>
 <Designation>sse</Designation>
</employee>

Is this possible to add XML element in between using xslt?
Please give me sample!

  • 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-16T17:55:27+00:00Added an answer on May 16, 2026 at 5:55 pm

    Here is an XSLT 1.0 stylesheet that will do what you asked:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <!-- Identity transform -->
       <xsl:template match="@* | node()">
          <xsl:copy>
             <xsl:apply-templates select="@* | node()"/>
          </xsl:copy>
       </xsl:template>
    
       <xsl:template match="Name">
          <xsl:copy-of select="."/>
          <Age>34</Age>
       </xsl:template>
    
       <xsl:template match="Dept">
          <xsl:copy-of select="."/>
          <Domain>Insurance</Domain>
       </xsl:template>
    </xsl:stylesheet>
    

    Obviously the logic will vary depending on where you will be getting the new data from, and where it needs to go. The above stylesheet merely inserts an <Age> element after every <Name> element, and a <Domain> element after every <Dept> element.

    (Limitation: if your document could have <Name> or <Dept> elements within other <Name> or <Dept> elements, only the outermost ones will have this special processing. I don’t think you intend for your document to have this kind of recursive structure, so it wouldn’t affect you, but it’s worth mentioning just in case.)

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

Sidebar

Related Questions

Here I i'm trying to parsing a XML in like below: <?xml version=1.0 encoding=utf-8
All of the names below are generic and not the actual names used. I
I know I'm missing something here. In the XSLT transformation below, the actual result
I auto generated an xsd file from the below xml and used xsd2code to
I have xml that essentialy looks like the following (my actual .xml is a
with the XML structure below: <root foo1=bar1 foo2=bar2 foo3=bar3> <foo1 foo1=bar1 /> <data> <foo1>bar1</foo1>
Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I
Below I have written a sample program that I have written to learn about
Below I present you some code which has completely been butchered by me. $(.gig).hover(function()
Below is a fine piece of artwork that represents a WPF form with a

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.