Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading and using an XML file as a database - Windows Phone 7 app

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

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?

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> 

Also I tried this

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

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

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?

Update: Maybe Xml Deserialization would work for me?

Thank you in advance

like image 907
George Lydakis Avatar asked Dec 12 '25 15:12

George Lydakis


1 Answers

If "Data.xml" is in the root of the project, make sure the Build Action is set to Content and your code should work.

like image 162
Matt Lacey Avatar answered Dec 14 '25 05:12

Matt Lacey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!