If you need to handle XML, xmlstarlet (http://xmlstar.sourceforge.net) is fantastic, and much more powerful than the standard line-oriented tools like sed and awk for this task.
The only issue I have with xmlstarlet is that it can be sort of a pain when there are xml namespaces in the document. Most of the time, you just have to pass it the long option that ignores them all together