In game development, the XML file often plays the role of describing the whole game world, configuring the basic game settings or defining the object properties in the game scenario. For processing an XML file, the .NET
framework supports several methods. In Windows Phone 7 XNA programming, if XML is a part of the game content, you can process the file in a way to suit your requirements. At present, the technique of writing the XML file importer and processor will help you. In the following recipe, you will learn this useful technique, and it is easy to extend for your own game.
The following steps will lead you to create the content importer and process for XML files:
1. Create a Windows Phone Game project named
XMLReader
. ChangeGame1.cs
toXMLReaderGame.cs
. Then, add a Content Pipeline Extension Library project in the solution namedXMLImporterProcessor
. AddPerson.cs, PersonWriter.cs, PersonXMLInput.cs, XMLImporter.cs
, andXMLProcessor.cs
files into...