2
\$\begingroup\$

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?

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

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:

enter image description here

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.