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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:10:15+00:00 2026-06-15T08:10:15+00:00

Example xml is: <a amp=a><b><c>this is the text</c></b></a> Needs to be transformed to: <a

  • 0

Example xml is:

<a amp="a"><b><c>this is the text</c></b></a>

Needs to be transformed to:

<a amp="a"><c>this is the text</c></a>
  • 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-15T08:10:16+00:00Added an answer on June 15, 2026 at 8:10 am

    Solution #1: A slight improvement to smaccoun‘s solution that would preserve any attributes on the c element (not necessary for example XML):

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="c">
            <xsl:copy-of select="." />
        </xsl:template>
    </xsl:stylesheet>
    

    Solution #2 Another alternative that leverages the built-in template rules, which apply-templates for all elements and copy all text():

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <!--identity template for the c element, it's decendant nodes, 
            and attributes (which will only get applied from c or 
            descendant elements)-->
        <xsl:template match="@*|c//node()|c">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    </xsl:stylesheet>
    

    Solution #3: A modified identity transform:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <!--identity template, copies all content by default-->
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    
        <!--don't generate content for these matched elements, 
            just apply-templates to it's children-->
        <xsl:template match="a|b">
            <xsl:apply-templates/>
        </xsl:template>     
    </xsl:stylesheet>
    

    Solution #4 If you know what you want, just copy it from a match on the root node

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="/">
            <xsl:copy-of select="a/b/c" />
        </xsl:template>
    </xsl:stylesheet>
    

    If you want to simply remove the <b> element from your input, then a modified identity transform should be used with a template matching the <b> element that simply applies templates to it’s children.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <!--identity template, copies all content by default-->
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    
        <!--don't generate content for the <b>, just apply-templates to it's children-->
        <xsl:template match="b">
            <xsl:apply-templates/>
        </xsl:template>     
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Microsoft SQL Server... declare @x xml set @x = '<Example>&lt;You &amp; Me&gt;</Example>' select
How to use special characteres like <,>,, and & in XML in Flex? Example:
This is an example XML file that would come from the Android Client. <test>
Given this example XML file: <doc> <tag> Hello ! </tag> <tag> My name is
This is an example xml from MSDN <?xml version=1.0?> <!-- A fragment of a
Using this xml example: <templateitem itemid=5> <templateitemdata>%ARN%</templateitemdata> </templateitem> <templateitem itemid=6> <templateitemdata></templateitemdata> </templateitem> I am
I have set of xml elements like this: <item code=<HTML_CODE> /> For example: <items>
I have this xml feed, as below: <GSP VER=3.2> <TM>0</TM> <Q>blue&blue</Q> <PARAM name=output value=xml_no_dtd
Example XML using element nodes: <?xml version=1.0 encoding=utf-8?> <users> <user> <name>David Smith</name> <phone>0441 234443</phone>
i've got following example xml: <entity id=1> <name>computer</name> <type>category</type> <entities> <entity id=2> <name>mac</name> <type>category</type>

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.