Building XML in Content Pipeline

Hi all

I’ve created a small list of “HistoryRegions” objects and populated the list then serialised it out to a file. I then created an XML file in the content pipeline via the CP application but now having problems building the data. Anyone have any idea. The current error I’m getting is:

An error occured parsing --> system.xml.xmlexception: “element” is an invalid XmlNodeType. Line 4, position 56. (note the app doesn’t allow me to copy and paste exact text).

Here is the XML:

<?xml version="1.0" encoding="utf-8"?> 135322552552552554294967295 232622552552552554294967295 367452552552552554294967295 497292552552552554294967295

and here is the class:

public class HistoryRegion
public string Key;
public int X;
public int Y;
//public byte B;
//public byte G;
//public byte R;
//public byte A;

public Color Color;

public HistoryRegion() { }

public HistoryRegion(string key, int x, int y, Color regionColor)
	Key = key;
	X = x;
	Y = y;
	//Color = regionColor;
	//B = regionColor.B;
	//G = regionColor.G;
	//R = regionColor.R;
	//A = regionColor.A;


I’ve tried changing it around and just saving out the RGB values but then when I use ‘[XmlIgnore]’ on the Color field, the error I get is that it expects to see the Color field in the xml - it appears to be ignoring the xmlignore attribute.

I’ve edited the xml and made it so Color is just ‘Color 4294967295 /Color’ (brackets removed) with the number shown and the number 0, but get an error about uint being to big or small.

Any ideas? All I want to load in is a list of “Key, X, Y, Color” from a xml file in the content pipeline (built to xnb)


Think I worked out the Color Xml - it needs to be just the html value - e.g:

Color FFFFFFFF /Color

and because I named the element the same as the class name “Color” I needed the XmlElement attribute above it in my class: (else it complained about it not existing.

public Color Color;

So far it seems to be ok and working now, but I wanted to add some extra properties on it that are not in the save file: e.g.

public string test;

but when I build the pipeline content with the above “test” field added I get the following error:

“the Xml element ‘test’ is required!” - How can I tell the build to ignore the extra fields?

Making it a property with a private set seems to work, but I want it as a public set (otherwise I would need to do methods to set it.

public string test { get; private set; } //works