【发布时间】:2011-09-20 23:08:33
【问题描述】:
我确实实现了一个 Web 应用程序(asp.net,c#),它有几个页面。每个页面都能够从 xml 文件中读取值并传递到每个页面中的几个文本框。用户有能够编辑值并保存,从而保存 xml 文件。我确实使用了 linq to xml。
我现在必须搬到 silverlight。所以我正在尝试在新的 silverlight 项目中实现相同的逻辑。我也在尝试在 silverlight 中使用 linq to xml。但是有些我无法读取 xml不在 xap 文件中的文件。这是我的代码
XDocument doc = Document.Load("C:\Data\Data.exe.config");
var applicationSettings = (from x in doc.Descendants("applicationSettings")
from kvpair in .Element("Data.Properties.Settings").Elements("setting")
select new
{
Name = kvpair.Attribute("name").Value,
Node = kvpair.Element("value")
}).ToDictionary(x => x.Name, y => y);
string Account = applicationSettings["Account no"].Node.Value.ToString();
txtAccountno.Text = AttendanceWindow;
string Details=applicationSettings["Details"].Node.Value.ToString();
txtDetails.Text = Details;
【问题讨论】:
标签: c# silverlight-4.0 linq-to-xml