Cover by Matt Smith, Chico Queiroz

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Creating XML text data automatically through serialization

Another way to create XML data structures from game objects and properties is by serializing the contents of an object automatically. This technique automatically generates XML for all the public properties of an object.

Getting ready

In the 0423_08_06 folder, you'll find the listings for all four classes described in this recipe.

How to do it...

To create XML text data through serialization, perform the following steps:

  1. Create a C# script called PlayerScore:
    // file: PlayerScore.cs public class PlayerScore { public string name; public int score; // default constructor, needed for serialization public PlayerScore() {} public PlayerScore(string newName, int newScore) { name = newName; score = ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required