Can someone please check why it isn't removing exact character (`ind`) from the string? 

When I execute below, the char `'<'` at position 17 is not removed, I see it's removing `'2'`, also I tried with `ind - 2` to remove `'<'` but it doesn't work for the next special character. 

Please note that I need to use the below code to remove special chars.

```
    static void Main(string[] args)
    {
        string path = "<X><A>this is AA<123 w<o<r<d</A></X>";
        int xx = 0;
        bool bFlg = true;
        XmlDocument x = new XmlDocument();
        while (bFlg)
        {
            try
            {
                xx++;
                x.LoadXml(path);
                bFlg = false;
            }
            catch (Exception ee)
            {
//"Name cannot begin with the '1' character, hexadecimal value 0x31. Line 1, position 18."
                string toBeSearched = "position";
                int ix = ee.Message.IndexOf(toBeSearched);

                if (ix != -1)
                {
                    var pos = ee.Message.Substring(ix + toBeSearched.Length);
                    pos = Regex.Replace(pos, @"[^\d]", "");
                    path = path.Remove(Convert.ToInt32(pos), 1);
                    bFlg = true;
                }
                else
                    throw new Exception(ee.Message);
                if (xx > 20)
                    break;
            }
        }
    }

```
['https://Stackoverflow.com/questions/52559052', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7991976/']
It's a little bit messy.. but given your current test case, it works.

```
string path = "<X><A>this is AA<123 w<o<r<d</A></X>";
int pathLength = path.Length;
List<int> positons = new List<int>();
for (int itr = 0; itr < pathLength; itr++) {
    if (path[itr] == '<') {
        for (int pointer = itr + 1; pointer < pathLength; pointer++) {
            if (path[pointer] == '<') {
                positons.Add(itr);
                break;
            } else if (path[pointer] == '>') {
                break;
            }
        }
    }
}
int offset = 0;
foreach(var pos in positons) {
    path = path.Remove(pos - offset, 1);
    offset++;
}

```
If the path is always enclosed within the same tags (since this was not specified, I'm not sure), it can be as simple as removing the leading and trailing tags:

```
const string LeadingTags = "<X><A>";
const string TrailingTags = "</A></X>";

string path = "<X><A>this is AA<123 w<o<r<d</A></X>";
int length = path.Length - LeadingTags.Length - TrailingTags.Length;
string value = path.Substring(LeadingTags.Length, length);
Console.WriteLine(value);

```

Prints the correct value:

> 
> this is AA<123 w<o<r<d
> 
> 
>