http://www.perlmonks.org?node_id=1004908


in reply to Adding Elements to XML

Also, generally speaking, use XPath expressions to navigate an XML structure, not hard code. The day will come when you have a structure to deal with that is not-quite what your code was hard-coded to expect. Therefore, as a general approach to this problem, use XPath to find the node(s) you want, then modify them.