public static string VerifyXmlChars(string content) { if (content == null) { throw new ArgumentNullException("content"); } var idx = XmlChar.IndexOfInvalid(content, true); if (idx < 0) { return(content); } throw new XmlException(string.Format("Invalid XML character was found in the content, at index {0}.", idx)); }