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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:36:26+00:00 2026-06-01T11:36:26+00:00

I have the following XML: <root> <section> <item name=a> <uuid>1</uuid> </item> </section> <section> <item

  • 0

I have the following XML:

<root>
<section>
    <item name="a">
        <uuid>1</uuid>
    </item>
</section>
<section>
    <item name="b">
        <uuid>2</uuid>
    </item>
</section>
</root>

I would like to transform it into the following XML:

<root>
<section>
    <item name="a">
        <uuid>1</uuid>
    </item>
    <item name="b">
        <uuid>2</uuid>
    </item>
</section>
</root>

Thanks in advance.

Update.

A slightly different example contains additional elements and attributes.

Input:

<root age="1">
<description>some text</description>
<section>
    <item name="a">
        <uuid>1</uuid>
    </item>
</section>
<section>
    <item name="b">
        <uuid>2</uuid>
    </item>
</section>
</root>

I would like to transform it into:

<root age="1">
<description>some text</description>
<section>
    <item name="a">
        <uuid>1</uuid>
    </item>
    <item name="b">
        <uuid>2</uuid>
    </item>
</section>
</root>
  • 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-01T11:36:27+00:00Added an answer on June 1, 2026 at 11:36 am

    Following Xsl should work:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
        <xsl:output indent="yes" omit-xml-declaration="yes"/>
        <xsl:strip-space elements="section item"/>
        <xsl:template match="/root">
            <root>
                <section>
                    <xsl:apply-templates select="section"/>
                </section>
            </root>
        </xsl:template>
    
        <xsl:template match="item">
            <xsl:copy-of select="."/>
        </xsl:template>
    
    </xsl:stylesheet>
    

    It gives:

    <root>
       <section>
          <item name="a">
             <uuid>1</uuid>
          </item>
          <item name="b">
             <uuid>2</uuid>
          </item>
      </section>
    </root>
    

    Update:

    For second example you can use following Xsl:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
        <xsl:output indent="yes" omit-xml-declaration="yes"/>
        <xsl:strip-space elements="root item"/>
    
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
       </xsl:template>
    
       <xsl:template match="description">
           <xsl:copy-of select="."/>
           <section>
               <xsl:apply-templates select="following-sibling::section/item"/>
           </section>
       </xsl:template>
    
       <xsl:template match="section" />
    
       <xsl:template match="item">
          <xsl:copy-of select="."/>
       </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
Hi I have the following xml <?xml version=1.0 encoding=UTF-8?> <root> <item> <name>john</name> <year>2010</year> </item>
I have the following XML: <Root> <Section name=xyz /> <Section name=abc> <Section name=def />
I have an XML structure like the following: <Root> <Base> <Greeting>Base Hello!</Greeting> <SpecialMessage>Base Special
I have the following xml and want to insert additional xml into it: <root>
Hi I have the following XML structure: <Root> <Persons> <PersonList Category=Employee> <Person Name=John Id=5
I have the following XML structure: <?xml version=1.0 encoding=utf-8?> <xml> <root> <Item> <taxids> <string>330</string>
Suppose I have the following XML: <root> <parent> <name>Luiz</name> <son><name>Luiz</name</son> <daugther><name>Cristina</name></daughter> </parent> <parent> <name>Cristina</name>
Suppose I have the following XML structure: <root> <item> <item1>some text is <b>here</b></item1> <item2>more
Let's say I have the following xml: <root> <person> <name>John</name> </person> <children> <person> <name>Jack</name>

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.