English 中文(简体)
视窗7(WP7)中的当地Xml文档
原标题:Loading local xml file in Windows Phone 7 (WP7)

我正试图装上我视窗7解决方案的XML文档。 我很想知道把档案列入项目的适当方式,然后将其与法典联系起来。 我目前的法典给我留下了一个错误。

NotSupportedException "An exception occurred during a WebClient request."

我的《网络法典》在这里被困。

WebClient workbenchAdConfigRequest = new WebClient();
workbenchAdConfigRequest.OpenReadCompleted += new OpenReadCompletedEventHandler(workbenchAdConfigRequest_OpenReadCompleted);
workbenchAdConfigRequest.OpenReadAsync(new Uri("/SampleData/SampleData.xml", UriKind.Relative));

以及活动主持人

private void workbenchAdConfigRequest_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        try
        {
            XElement xml = XElement.Load(e.Result);         
        }
        catch
        {
            //return
        }
    }

页: 1 我已经确定这些特性。

Build Action: Embedded Reference Copy to Output Directory: Do Not Copy Custom Tool: MSBuild:Compile

您能否从申请的“file路”中查阅当地档案?

问题回答

您也可以将“私人行动”定在您的XML档案中,然后在以下法典中:

using System.Xml.Linq;

......

XElement appDataXml;

StreamResourceInfo xml = Application.GetResourceStream(new Uri("yourxmlfilename.xml", UriKind.Relative)); 
appDataXml = XElement.Load(xml.Stream);

这里如何装上XML档案:

将“私人行动”规定在您的XML档案的特性中为“资源”,然后在法典中:

using System.Xml.Linq;

......

XElement appDataXml;

StreamResourceInfo xml = Application.GetResourceStream(new Uri("/yourprojectname;component/yourxmlfilename.xml", UriKind.Relative)); 
appDataXml = XElement.Load(xml.Stream);

这里有一个工程项目,I在MSDN上张贴,只是把XML储存在XAP,并用XDocument/LINQ装载,结果对清单Box具有约束力。

http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/0baf666f-5797-4917-9228-0a66dead8f72”rel=“nofollow”>,将Linq数据来源并入一个名单箱





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签