Load xml file

Nov 3, 2010 at 10:53 AM


I have an .xml file that I want to load in the WP7 application using the sterling project. It's possible? I did not see any examples on how I could use an existing xml file to query data.


Nov 3, 2010 at 11:46 AM

There are a few ways to do this. You could create an object that mirrors the information in the XML file, then deserialize to the object. You can also use LINQ-to-XML to parse the contents. If you want to take advantage of the indexing features in Sterling, you'll then need to save it to the database and then you can query on those.

Nov 3, 2010 at 11:55 AM

The xml file is kind of large and I think will be great to use indexing. How can I save the xml file to database? I need to do this at every application startup?

Nov 3, 2010 at 12:06 PM

No, the point of Sterling is that it saves it to isolated storage so you don't always have to deal with it. Basically, let's say the file describes a set of Widgets and attributes on each Widget. What I'd do is in the start up, check to see if there are entries in the database. If not, I'd load and parse the XML file into a set of Widget objects and then call Save on them to save them to the database. From that point forward, you can query and load Widgets and have them available any time you run the application without having to reference the XML file again