I haven't had much XML experience, but looking at XML::Twig's man page on CPAN, it probably would do this. The author will most likely be by to club me over the head if I'm wrong, however. There are probably other modules in the XML class that will help as well.
--
Me spell chucker work grate. Need grandma chicken.