[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Flattening a XML tree

Subject: Flattening a XML tree
From: Mir Farooq Ali <mfali@xxxxxxxxxxxxxxxx>
Date: Mon, 1 Oct 2001 23:59:54 -0400 (EDT)
flattening an xml tree
Hi,

I have an input tree that looks like this

<?xml version="1.0"?>
<Tree>
 <TreeNode id="1" weight="5">
  <TreeNode id="2" weight="3">
   <TreeNode id="6" weight="2"/>
   <TreeNode id="7" weight="2"/>
   <TreeNode id="8" weight="2"/>
  </TreeNode>
  <TreeNode id="3" weight="4">
   <TreeNode id="9" weight="3">
    <TreeNode id="11" weight="2"/>
    <TreeNode id="12" weight="2"/>
   </TreeNode>
   <TreeNode id="10" weight="2"/>
  </TreeNode>
  <TreeNode id="4" weight="2"/>
  <TreeNode id="5" weight="2"/>
 </TreeNode>
</Tree>

I need to flatten the tree to a structure that looks like this. I've
looked at the archives, but haven't found an answer.

<?xml version="1.0"?>
<Tree>
  <TreeNode id="1" weight="5">
    <TreeNode id="2" weight="3"/>
    <TreeNode id="3" weight="4"/>
    <TreeNode id="4" weight="2"/>
    <TreeNode id="5" weight="2"/>
    <TreeNode id="6" weight="2"/>
    <TreeNode id="7" weight="2"/>
    <TreeNode id="8" weight="2"/>
    <TreeNode id="11" weight="2"/>
    <TreeNode id="12" weight="2"/>
    <TreeNode id="9" weight="3"/>
    <TreeNode id="10" weight="2"/>
  </TreeNode>
</Tree>

Any help is appreciated.

Thanks,

-Farooq.

+---------------------------------+-------------------------------------+
| Ph.D. Candidate                 | (540) 5520967 (R)  (540) 2313986 (W)|
| Department of Computer Science  | Email:                mfali@xxxxxx  |
| Virginia Tech.                  | Web: http://csgrad.cs.vt.edu/~mfali |
+---------------------------------+-------------------------------------+



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.