Install the BaseX database, then use it's "standalone command-line mode" like this:
basex -i - //element@attribute < filename.xml
or
basex -i filename.xml //element@attribute
The query language is actually XQuery (3.0), not XPath, but since XQuery is a superset of XPath, you can use XPath queries without ever noticing.