Any help is highly welcome!

I'm no expert in this subject but here's a XSLT transform from the original XML into one with the correct order

#!perl use strict; use XML::LibXSLT; use XML::LibXML; =head1 test.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Tr +ansform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="TRGROUP"> <xsl:copy> <xsl:apply-templates select="COLS"/> <xsl:apply-templates select="COLSPEC"/> <xsl:apply-templates select="THEAD"/> <xsl:apply-templates select="TBODY"/> </xsl:copy> </xsl:template> </xsl:stylesheet> =cut my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new(); my $stylesheet = $xslt->parse_stylesheet_file('test.xsl'); my $xml; { local $/=''; $xml = <DATA>; } my $source_doc = $parser->parse_string( $xml ); my $result = $stylesheet->transform( $source_doc ); print $stylesheet->output_string( $result ); __DATA__ <TABLE> <TRGROUP> <COLS>AA</COLS> <TBODY>A</TBODY> <COLSPEC>XX</COLSPEC> <THEAD>1</THEAD> </TRGROUP> <TRGROUP> <COLSPEC>XX</COLSPEC> <TBODY>B</TBODY> <THEAD>2</THEAD> <COLS>BB</COLS> </TRGROUP> <TRGROUP> <TBODY>C</TBODY> <COLS>CC</COLS> <COLSPEC>ZZ</COLSPEC> <THEAD>3</THEAD> </TRGROUP> </TABLE>
poj

In reply to Re: xml using XML::Simple reording of XML-Content by poj
in thread xml using XML::Simple reording of XML-Content by tobias_hofer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.