小编mwi*_*ann的帖子

尝试解析plist文档时出现NotSupportedException

我正在为我工​​作的公司开发Windows Phone 7应用程序.对于配置部分,我想分享用于我们的iPhone应用程序并存储在plist文件中的远程服务器上的配置.

我使用System.Xml.Linq.XDocumentParse是使用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)

xml linq-to-xml windows-phone

0
推荐指数
1
解决办法
1376
查看次数

标签 统计

linq-to-xml ×1

windows-phone ×1

xml ×1