internal static string ToValidXmlId(string item)
{
string output = item.Replace(" ", "");
// This conforms to http://www.w3.org/TR/REC-xml/#NT-Name except that we don't handle valid characters above FFFF.
string validStartRanges =
":A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
string validChars = validStartRanges + "\\-.0-9\u00b7\u0300-\u036F\u203F-\u2040";
output = Regex.Replace(output, "[^" + validChars + "]", "_");
if (!new Regex("^[" + validStartRanges + "]").IsMatch(output))
return "f" +output;
return output;
}