【发布时间】:2011-12-02 16:18:17
【问题描述】:
我有一个这样的 xml:
<item>
<name>chuck - norris</name>
</item>
我可以从那里获得全名并将其添加到列表框中:
.......
.......
public class helperclass
{
string helper;
public string Helper
{
get {return helper; }
set {helper = value; }
}
}
.......
.......
//xml comes from internet
void something_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
XElement xml = XElement.Parse(e.Result);
var info = from somexml in xml.Descendants("item")
select new helperclass
{
Helper = (string)somexml.Element("name")
};
listBox1.ItemsSource = info;
.......
但是我怎样才能用换行符替换那个“ - ”,这样我才能得到:
查一下
诺里斯
代替:
查克-诺里斯
以及如何只获得名字?
【问题讨论】:
-
您尝试过使用拆分吗?