У меня есть строка [XML], я хочу найти теги, содержащие слово, и заменить этот тег другим именем.
Я пытался использовать это, но безуспешно:
var regex = new Regex(@"\bKeyValueOfstringOutcome\b", RegexOptions.IgnoreCase);
string result = regex.Replace(xml.Document.ToString(), "");
Это мой XML:
<Response>
<Outcome>
<KeyValueOfstringOutcomeTest1>
<Key>Icon</Key>
<Value>
<DataType>System.String</DataType>
<Field>Icon</Field>
<Value>O</Value>
</Value>
</KeyValueOfstringOutcomeTest1>
<KeyValueOfstringOutcomeTest2>
<Key>IconDescription</Key>
<Value>
<DataType>System.String</DataType>
<Field>IconDescription</Field>
<Value>Old</Value>
</Value>
</KeyValueOfstringOutcomeTest2>
<KeyValueOfstringOutcomeTest3>
<Key>IconLongDescription</Key>
<Value>
<DataType>System.String</DataType>
<Field>IconLongDescription</Field>
<Value>Older</Value>
</Value>
</KeyValueOfstringOutcomeTest3>
</Outcome>
</Response>
Мне нужно найти узлы, которые содержат KeyValueOfstringOutcome, и заменить KeyValueOfstringOutcomeTest1, KeyValueOfstringOutcomeTest2, KeyValueOfstringOutcomeTest3 на KeyValueOfstringOutcome.