Affichage des articles dont le libellé est Control-M. Afficher tous les articles
Affichage des articles dont le libellé est Control-M. Afficher tous les articles

lundi 21 septembre 2015

Flatten and XML file (perl)

This perl one-liner is useful in case you need to "flatten" and XML file.



PERL_CONVERT="use XML::Simple; print XMLout(XMLin('-', KeepRoot => 1), AttrIndent => 1, KeepRoot => 1, XMLDecl => '');"

To be used like this :

/usr/bin/perl -e "$PERL_CONVERT" > $TMPFILE


Whatever input you have (in XML), the goal is to have a "comparable" ouptut that will respect the XML structure :
FROM:


...

...

 TO:


attr1="value1"
attr2="value2"
...
attr3="value3"
>

...




...


Specifically, this is really useful if you need to merge 2 different versions of  your XML file, like for example in SVN.