← Prev in month ← Prev in thread

Existing libraries/mechanisms for alphabetically sorting and formatting XML files

From
Peter Loh Yoon Chao <>
To
Date
2004-02-10T01:50:30Z
ID
<>
Thread
Existing libraries/mechanisms for alphabetically sorting and formatting XML files
Hi,

I currently have XML files with a flat key-value structure and the elements
are unsorted and without proper formatting, e.g.

    <main>
<e.f.g>
  <value xml:lang="en">data 2</value>
        </e.f.g>
        <a.b.c>
<value xml:lang="en">data 1</value>
        </a.b.c>
        ...
     </main>

Are there any existing libraries or mechanisms to do the following?
- convert the file structure into a hierarchical tree structure
- alphabetically sorting the individual elements at each level
- indent the individual nodes properly in the resulting XML file

The resulting XML file should look something like the following:

    <main>
        <a>
	<b>
	  <c>
                <value xml:lang="en">data 1</value>
	  </c>
	</b>
        </a>
        <e>
	<f>
	  <g>
                <value xml:lang="en">data 2</value>
	  </g>
	</f>
        </e>
        ...
     </main>

I would rather not reinvent the wheel if there are existing
libraries/mechanisms to do this sort of thing.  Thanks in advance for any
input.

Peter
← Prev in month ← Prev in thread