in reply to Creation of Hash necessary?

Using the same sample data as Athanasius and XML::XSH2, a wrapper around XML::LibXML:
open file.xml ; for /data/class[@id]/* set @class ../@id ; ls /data/class/* | cat > file2 ;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ