You can use apache common lang library to escape a string.
org.apache.commons.lang.StringEscapeUtils
String escapedXml = StringEscapeUtils.escapeXml("the data might contain & or ! or % or ' or # etc");
But what you are looking for is a way to convert any string into a valid XML tag name. For ASCII characters, XML tag name must begin with one of _:a-zA-Z and followed by any number of character in _:a-zA-Z0-9.-
I surely believe there is no library to do this for you so you have to implement your own function to convert from any string to match this pattern or alternatively make it into a value of attritbue.
<property name="no more need to be encoded, it should be handled by XML library">0.0</property>