Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks to me that you want 2 things for your XML:</p> <ul> <li>no attributes, hence the <code>NoAttr</code> option in the XML::Simple object creation</li> <li>the order of the elements should be as specified</li> </ul> <p>I am not sure why you don't want attributes in your XML, and why the data structure you use to create it has them. You may want to look into that. In any case XML::Simple gives you this feature.</p> <p>For the second part, XML::Simple doesn't keep the order, and I have found no way to make it do it, so you will need something else.</p> <p>For a quick and dirty solution, A little bit of XML::Twig in there would do:</p> <pre><code># instead of the print FH $data; line my $twig= XML::Twig-&gt;new( )-&gt;parse( $data); $twig-&gt;root-&gt;set_content( map { $dtwig-&gt;root-&gt;first_child( $_) } (qw( name SSIDConfig connectionMode connectionType autoSwitch MSM)) ); $twig-&gt;print( \*FH); </code></pre> <p>A couple more comments: </p> <ul> <li>you can't use 'WLAN Profile` as the root tag, XML names cannot include spaces</li> <li>it is generally considered polite, when you ask a question about Perl, to show code that uses strict and warnings</li> <li>the proper way to open the output file would be <code>my $out_file= xml4.txt; open ( my $fh,'&gt;', $out_file) or die "cannot create $out_file: $!";</code> (or use <code>autodie</code> instead of the <code>die</code>), using 3 args open and lexical filehandles is a good habit (this message from the 3-arg open police department ;--)</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload