How to transform results of a select statement formatted as XML? When I run the command

mysql EvePlanataryExpenses --xml -uuser -p -e "SELECT sTransactionDateTime, SUM(sQuantity * sPrice) as 'profit' FROM sell GROUP BY sMonth;" |sed '/^\s*$/d'


I get the following output

&lt;?xml version="1.0"?&gt;
&lt;resultset statement="SELECT sTransactionDateTime, SUM(sQuantity * sPrice) as 'profit' FROM sell GROUP BY sMonth" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;row&gt;
    &lt;field name="sTransactionDateTime"&gt;2016-10-13&lt;/field&gt;
    &lt;field name="profit"&gt;1177089967.25&lt;/field&gt;
  &lt;/row&gt;
&lt;/resultset&gt;


Is it possible to remove the statement="text" from the root element, and set the field name to something else than &lt;field name=""&gt;&lt;/field&gt; from the SQL query itself?

I saw something here that I thought I could use, but can't make it work.

Or would I need to run the output through a parser (Java, PHP, something else) and get that to remove the statement from the root element and rename the field elements?
The query doesn't know (or care) how its results might be formatted by the client (the mysql program in this case), so no, you cannot influence the XML in the query itself. What you're looking for is called XSL transformation, for which there are command line tools (e.g. xmlstarlet) through which you can pipe your output.