读取XML文件并将其用作数据库-Windows Phone 7应用 [英] Reading and using an XML file as a database - Windows Phone 7 app

查看:60
本文介绍了读取XML文件并将其用作数据库-Windows Phone 7应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序应从xml文件读取数据,然后使用该数据.

I have an app which should read the data from an xml file and then use that data.

如何在应用程序中导入xml文件(其代码是什么)以及如何使用该xml文件中的数据?

How can I import an xml file in my app (what's the code for that) and how can I use the data from that xml file?

这是我使用的xml数据库的示例:

Here's an example of the xml database I use:

<Data>
  <Animals>
    <A>
      <word>Ant</word>
      <word>Aardwark</word>
    </A>
    <B>
      <word>Bear</word>
      <word>Boa</word>
   </B>
  </Animals>
</Data> 

我也尝试过

XDocument loadedData = XDocument.Load("Data.xml"); 

从xml文件中读取数据,但是没有用.

to read the data from the xml file but didn't work.

我还能以什么形式使用xml数据?换句话说,xml数据是字符串格式还是"X-Something"格式?

Also the in what form can I use the xml data? In other words the xml data would be in a string format or an "X-Something" format?

更新:也许Xml反序列化对我有用?

Update: Maybe Xml Deserialization would work for me?

提前谢谢

推荐答案

如果您已经拥有文件,并且对每个应用程序实例都是相同的,则不需要IsoStore(假设您只需要读取它).只需执行 Matt说,以便快速获取内容.我建议将其反序列化为一个单独的类,以便您可以轻松地重用和修改数据.

No need for IsoStore if you already have the file and it is the same for every app instance (given that you only need to read it). Simply do what Matt said to quickly get the contents. I would recommend deserializing it to a separate class, so that you can easily reuse and modify the data.

现在,如果要存储数据,则以后可以轻松地序列化现有类并将其存储在本地.如果您想更深入地了解数据存储,可以使用 SQL CE (包含在Mango中),可让您处理SDF文件(顺便说一句,可以与应用程序实例分别加载).另外,一个好主意是研究英镑DB (将使用IsoStore).

Now, if you want to store the data, you can later easily serialize the existing class and store it locally. In case you want to go a bit deeper into data storage, you could use SQL CE, that is included in Mango and will allow you to manipulate SDF files (which, by the way, can be loaded separately with app instances). Also, a good idea would be to look into Sterling DB (will use IsoStore).

这篇关于读取XML文件并将其用作数据库-Windows Phone 7应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆