我正在为我工作的公司开发Windows Phone 7应用程序.对于配置部分,我想分享用于我们的iPhone应用程序并存储在plist文件中的远程服务器上的配置.
我使用System.Xml.Linq.XDocument
的Parse
是使用WebClient实例下载的字符串.
这是代码:
Uri plistLocation = new
Uri(@"http://iphonevnreporter.vol.at/Settings.bundle/mw_test.plist");
WebClient client = new WebClient();
try
{
client.DownloadStringCompleted += ((sender,e) => {
if (e.Error == null)
{
XDocument xdoc = XDocument.Parse(e.Result);
//XElement element = XElement.Parse(e.Result.ToString());
var dictItems = xdoc.Descendants("dict");
foreach (XElement elem in dictItems)
{
}
}
});
}
catch (Exception e)
{
}
client.DownloadStringAsync(plistLocation);
Run Code Online (Sandbox Code Playgroud)
在这个例子中,plist只是dict
在根元素下面有一个元素plist
,然而我正在接收NotSupportedException
.异常发生在XDocument.Parse(e.Result)
.
这是StackTrace:
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDeclaration..ctor(XmlReader r)
at System.Xml.Linq.XDocument.Load(XmlReader …
Run Code Online (Sandbox Code Playgroud)