Hi Peter,
thanks again for you time and guidance.
I was looking at the regular experssion way and found this expression to give me the value of the tag. One catch here, this expression fails when the value is something like this:
Code:
<ContactFirstName><Elke123@><</ContactFirstName>
It just returns '<' character.
Other than that this expression returns the tag value as expected.
Now, in my source xml there are no nested tags. Guess I am saved for now.
This is how it looks now:
Code:
private string CleanupXml(string[] incidentXml)
{
string output = string.Empty;
for (int i = 0; i < incidentXml.Length; i++)
{
output = Regex.Replace(incidentXml[i], "<[^<>]+>", "");
if (output.Contains("&"))
{
output = output.Replace("&", "&");
incidentXml[i] = incidentXml[i].Replace(incidentXml[i], output);
}
else if (output.Contains("'"))
{
output = output.Replace("'", "'");
incidentXml[i] = incidentXml[i].Replace(incidentXml[i], output);
}
else if (output.Contains("\""))
{
output = output.Replace("\"", """);
incidentXml[i] = incidentXml[i].Replace(incidentXml[i], output);
}
else if (output.Contains("<"))
{
output = output.Replace("<", "<");
incidentXml[i] = incidentXml[i].Replace(incidentXml[i], output);
}
else if (output.Contains(">"))
{
output = output.Replace("<", ">");
incidentXml[i] = incidentXml[i].Replace(incidentXml[i], output);
}
}
StringBuilder sb = new StringBuilder();
foreach (string item in incidentXml)
{
sb.Append(item);
}
return sb.ToString();
}
I was running out of time and had to comeup with some solution.
Hence the above implementation.
Your implementation should allow me to fine tune the search and replace without any hassels. I will keep that for the second release.
Many thanks again.
Regards.