Have you looked at xmlstarlet (particularly the select subcommand), dasel, or petl ? They are command line programs designed for editing xml programatically.