O'Reilly logo

Windows® Phone 7 Application Development 24-Hour Trainer by Brian Faucher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18. Working with Data

In Lesson 15 you learned how to consume XML from a web service and bind it to elements in your application. If you want the user to be able to use your application when networking is not available, such as when the user is on an airplane, you will want to provide a means of populating the data from a local data file.

READING FROM AN XML FILE

You could have your application pull down a copy of the most current version of the data file when the user is connected to the Internet and store the data as an XML file in the program's isolated storage. This will serve as the source of data when an Internet connection is unavailable. You could include a base version of the XML file with your application for use until the XML file is updated.

Adding the XML File

If you are building an e-commerce application and want to include a default set of products with the application, you can include an XML file such as the following:

<JHProducts> <Product> <ProductID>7000</ProductID> <ProductCode>EV100-11</ProductCode> <ProductType>Anniversary</ProductType> <ProductIntroductionDate>All Year </ProductIntroductionDate> <ProductName>The Perfect Dozen</ProductName> <ProductDescription>A dozen red roses are always perfect, always savored. We add even more charming beauty with seeded eucalyptus and spiral eucalyptus. Item number EV 100-11.</ProductDescription> <ProductImageURL>EV100-11.jpg</ProductImageURL> <ProductImageURLlarge>EV100-11.jpg</ProductImageURLlarge> <UnitPrice>$60.00</UnitPrice> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required