in reply to Simple modification of XML file

With XML::XSH2, something like this will do:
open file.xml ; if not(/path/to/elem) insert element elem into /path/to ; save :b ;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ