Getting sum of a field in xml

To move sub-fields to the top level you can use code like this.