I am trying to develop an XML export feature to give my application users to export their data in an XML format. I have got this feature ready and working until it started f
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.
0.0