There's /usr/bin/xpath but that's for querying only it seems. Would be pretty straightforward to make one for setting arbitrary data.
OK, I wrote one. Please look at this:
http://www.salstar.sk/pub/salpack/usr/sbin/virsh-pyquery
This script uses pyquery, jquery based selector syntax. If you like jquery selectors, then you will like it. It can add/delete/remove/update entities or attributes.
Very cool! Something like that should be implemented as a virsh subcommand (but it would likely use xpath syntax since that's what libvirt uses internally).
OK, try to look at xpath version with some enhancements:
http://www.salstar.sk/pub/salpack/usr/sbin/virsh-xpath
It's still beta quality, but functional.
Example options: # Query boot options: --guest NAME --query //os/boot # Add an element with attributes: --guest NAME //os --add bios --attr useserial=yes # Update attribute of an element: --guest NAME //devices/disk/driver --update --attr cache=none # Remove attributes: --guest NAME //disk/driver --remove cache --remove type # Delete element: --guest NAME '//os/boot[@dev="hd"]' --delete
SAL