I am trying to convert a file to XML format that contains some special characters but it's not getting converted because of that special characters in the data. I have already this regex code still it's not working for me please help.
The code what I have tried:
string filedata = @"D:\readwrite\test11.txt";
string input = ReadForFile(filedata);
string re1 = @"[^\u0000-\u007F]+";
string re5 = @"\p{Cs}";
data = Regex.Replace(input, re1, "");
data = Regex.Replace(input, re5, "");
XmlDocument xmlDocument = new XmlDocument();
try
{
xmlDocument = (XmlDocument)JsonConvert.DeserializeXmlNode(data);
var Xdoc = XDocument.Parse(xmlDocument.OuterXml);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}