替换元素字符串数组(暂停)Replace element in string array [on hold]

- 此内容更新于:2015-01-06
主题:

原文:

I have a string array like this string [] items = {"<one>one</one>","<two>two</two>","<three>three</three>"};

how to find and replace element by node and replace string inside node - for example <three>blah-blah</three>

then i should have a string array like this string [] items = {"<one>one</one>","<two>two</two>","<three>blah-blah</three>"};

Oscar的回复:到目前为止,你试过什么?

(原文:What have you tried so far?)

CodeCaster的回复:到底你有困难吗?在一个数组循环吗?替换字符串?替换数组元素?

(原文:What exactly are you having trouble with? Looping over an array? Replacing strings? Replacing array elements?)

Tim Schmelter的回复:在项目= items.Select(s = s.StartsWith(“& lt;three>“)? String.Format(“& lt;three> { 0 } & lt;three>“‌& # 8203;,“blah-blah"):s).ToArray()

(原文:items=items.Select(s=>s.StartsWith("<three>")?String.Format("<three>{0}<three>"‌​,"blah-blah"):s).ToArray())

David Heffernan的回复:你确定你是# 39;解析XML ?

(原文:Are you sure you aren't parsing XML?)

Hurricane的回复:这是一个字符串

(原文:No this is a string)