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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:38:45+00:00 2026-06-11T22:38:45+00:00

I have: <nodes> <node> <name>node1</name> <other>stuff1</other> <node> <name>node11</name> <other>stuff11</other> </node> <node> <name>node12</name> <other>stuff12</other> </node>

  • 0

I have:

<nodes>
  <node>
    <name>node1</name>
    <other>stuff1</other>
    <node>
      <name>node11</name>
      <other>stuff11</other>
    </node>
    <node>
      <name>node12</name>
      <other>stuff12</other>
    </node>
  </node>
  <node>
    <name>node2</name>
    <other>stuff2</other>
  </node>
  <node>
    <name>node3</name>
    <other>stuff3</other>
  </node>
</nodes>

I want to end up with a flat structure like:

<nodes>
  <node>
    <name>node1</name>
    <other>stuff1</other>
  </node>
  <node>
    <name>node11</name>
    <other>stuff11</other>
  </node>
  <node>
    <name>node12</name>
    <other>stuff21</other>
  </node>
  <node>
    <name>node2</name>
    <other>stuff2</other>
  </node>
  <node>
    <name>node3</name>
    <other>stuff3</other>
  </node>
</nodes>

This is a simple example but I want to copy all elements in each node, but not the nested ‘node’ elements. I tried the copy-of to preserve the tags but that also preserves the nesting. I also tried copy but that leaves out all children.

Any ideas?

  • 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-11T22:38:47+00:00Added an answer on June 11, 2026 at 10:38 pm

    This should do what you’re after. For the top-level nodes element it applies templates for all descendant node elements in document order. For each node it copies all the non-node child elements.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="xml" indent="yes" />
    
      <xsl:template match="node">
        <xsl:copy><xsl:copy-of select="*[local-name() != 'node']"/></xsl:copy>
      </xsl:template>
    
      <xsl:template match="/nodes">
        <xsl:copy><xsl:apply-templates select="descendant::node" /></xsl:copy>
      </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 a node (node a) with which various other nodes (node b/c/d/e) references.
If we have a node related with other nodes by the same type of
I have to read the xml node name from the following XML, but I
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);
I have a tree, each node contains an array children nodes (Node *children_nodes), as
I have a d3 force-directed graph that contains a group of nodes: var node
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {
I have the following model in django: class Node(models.Model): name = models.CharField(max_length=255) And this
Greetings! I have some XML like this: <Root> <MainSection> <SomeNode>Some Node Value</SomeNode> <SomeOtherNode>Some Other

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.