# How do I load Gleed 2D levels in WP7 XNA game?

I've been trying so long to use this modified version of GLEED2D that includes WP7 support,

I'm stuck into loading the level into my game, now my Game1.cs class has the following:

    protected override void Initialize()
{

Stream stream = TitleContainer.OpenStream("Content/leveltest.xml");
XElement xml = XElement.Load(stream);
level = LevelLoader.Load(xml);
base.Initialize();
}


I included the XML file of my level into Content Directory, when I try to build the solution, It gives this error:

XML is not in the XNA intermediate format. Missing XnaContent root element.


I didn't find any reference on how to fix it on the developer's blog or the github WiKi

Any Idea?

• You need to look at this tutorial for loading XML in XNA: msdn.microsoft.com/en-us/library/ff604979.aspx – John McDonald Jan 29 '12 at 5:54
• @JohnMcDonald I just did that, what should I replace the "<Asset Type="MyDataTypes.PetData[]">" in the example with ? – smohamed Jan 29 '12 at 6:21

## 1 Answer

The problem is that you're trying to build the XML file using the XNA's Content Pipeline. However, in the source code you posted, the XML file is being loaded at runtime using the LINQ to XML API (XDocument) so it doesn't need to go through the content pipeline.

To solve the problem, go to the Solution Explorer, browse into your Content project to your XML file, and then on its Properties, change the Build Action property from Compile to Content, and also enable the Copy to Output Directory property. See picture below:

This way your XML file will still be copied to the Content folder, without being built by the XNA's Content Pipeline.