I haven't tried to find out exactly what is wrong with your XML - it's probably the lack of a namespace. But here is the correct XML:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Generic="System.Collections.Generic">
<Asset Type="Generic:List[string]">
<Item>Audi</Item>
<Item>BMW</Item>
<Item>Nissan</Item>
<Item>Volvo</Item>
</Asset>
</XnaContent>
Under the hood the XmlImporter
uses the IntermediateSerializer
class. So a small program like the following can be used to determine what your XML should look like:
var test = new List<string>(){ "Audi", "BMW", "Nissan", "Volvo" };
var sb = new StringBuilder();
using(XmlWriter writer = XmlWriter.Create(sb))
{
IntermediateSerializer.Serialize(writer, test, null);
}
Console.Write(sb.ToString());
(You can even convert the output to a stream, pass it to the Deserialize
method, and reconstruct the object - just to be doubly-sure it's working. Also it is probably worth putting the right encoding in the header - eg: StringBuilder
is utf-16.)
For some in-depth information about IntermediateSerializer
, take a look at Shawn Hargreaves' blog, starting with this post and continuing through the archives until August 2008.
XmlImporter
, part of the XNA Content Pipeline. The pipeline deserializes the XML in order to convert it to an XNB file (which will then be loaded byContentManager
at runtime). \$\endgroup\$