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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:48:10+00:00 2026-06-09T02:48:10+00:00

So, considering this XML: <root> <table> <tr> <td>asdf</td> <td>qwerty</td> <td>1234 <p>lorem ipsum</p> 5678</td> </tr>

  • 0

So, considering this XML:

<root>
    <table>
      <tr>
        <td>asdf</td>
        <td>qwerty</td>
        <td>1234 <p>lorem ipsum</p> 5678</td>
      </tr>
    </table>
<root>

…how might I transform it to look like this?

<root>
    <table>
      <tr>
        <td><BLAH>asdf</BLAH></td>
        <td><BLAH>qwerty</BLAH></td>
        <td><BLAH>1234 <p>lorem ipsum</p> 5678</BLAH></td>
      </tr>
    </table>
</root>

Every instance of  <td>  would then be containing the  <BLAH> element, and the contents of each  <td>  would then be within the new node.


…so far, I have this XSL which is wrapping each  <td>  element with the new node, but on the outside and not on the inside:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>

    <!-- identity rule -->
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="table//td">
        <BLAH>
            <xsl:copy>
                <xsl:apply-templates select="@*"/>
                <xsl:apply-templates select="node()"/>
            </xsl:copy>
        </BLAH>
    </xsl:template>
</xsl:stylesheet>

…this is producing this undesired result:

<root>
  <table>
    <tr>
      <BLAH><td>asdf</td></BLAH>
      <BLAH><td>qwerty</td></BLAH>
      <BLAH><td>1234 <p>lorem ipsum</p> 5678</td></BLAH>
    </tr>
  </table>
</root>

tested at http://xslt.online-toolz.com/tools/xslt-transformation.php

  • 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-09T02:48:12+00:00Added an answer on June 9, 2026 at 2:48 am

    Just move <BLAH> inside of the xsl:copy:

    <xsl:template match="td">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <BLAH>
                <xsl:apply-templates select="node()"/>
            </BLAH>
        </xsl:copy>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering this xml document: DECLARE @X XML (DOCUMENT search.SearchParameters) = '<parameters xmlns=http://www.educations.com/Search/Parameters.xsd xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> <parameter
I have XML file which looks like this: <?xml version=1.0?> <results> <row id=100><name>name blah</name></row>
How to parse nested xml in sql server into single table. Considering RowGuid is
How can I make a XSLT to transform this: <root> <element>This <element>is</element> </element> <element>normal!</element>
I've got a class that when serialized to XML looks like this (generalized for
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
Considering this code with 3 differents function call semantics: void f(void){ puts(OK); } int
considering this example: public static void main(final String[] args) { final List<String> myList =
Considering this question of SO, where whole C# in-memory compiler is being called. When
Considering this article Developing a MVC component for Joomla , following is the code

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.