Having trouble building XML in content pipeline tool

I’m having trouble getting my XML in the right format to build in the content pipeline tool. I used TexturePacker (free version) to generate xml for my spritesheet. It looks like this.

<TextureAtlas imagePath="testsheet.png" width="497" height="98">
    <sprite n="stand/sample_stand_small.png" x="1" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small1.png" x="56" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small2.png" x="111" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small3.png" x="166" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small4.png" x="221" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small5.png" x="276" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small6.png" x="331" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small7.png" x="386" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small8.png" x="441" y="1" w="55" h="96"/>
</TextureAtlas>

I’ve created separate data project with a class which looks like below. I have also set up the proper references between my main project and data project.

namespace SheetData
{
    [XmlRoot("TextureAtlas")]
    public class TextureAtlas
    {
        [XmlAttribute("imagePath")]
        public string imagePath;

        [XmlAttribute]
        public int width;

        [XmlAttribute]
        public int height;

        [XmlElement("sprite")]
        public List<SheetSprite> sheetSprites;
    }

    public class SheetSprite
    {
        [XmlAttribute]
        public string n;

        [XmlAttribute]
        public int x;

        [XmlAttribute]
        public int y;

        [XmlAttribute]
        public int w;

        [XmlAttribute]
        public int h;
    }
}

I then tried to convert my XML to the required format for Monogame as follows.

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:ns="Microsoft.Xna.Framework">
  <Asset Type="SheetData.TextureAtlas" imagePath="testsheet.png" width="497" height="98">
    <sprite n="stand/sample_stand_small.png" x="1" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small1.png" x="56" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small2.png" x="111" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small3.png" x="166" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small4.png" x="221" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small5.png" x="276" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small6.png" x="331" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small7.png" x="386" y="1" w="55" h="96"/>
    <sprite n="walk/walk_small8.png" x="441" y="1" w="55" h="96"/>
  </Asset>
</XnaContent>

But when I try to build in the content pipeline tool. I get the error, “The Xml element ‘imagePath’ is required, but element ‘sprite’ was found at 4:6. Try changing the element order or add missing elements.”

As shown in the original XML and the data class, “imagePath” is supposed to be an attribute of TextureAtlas, not an element. How can I get it to read the elements and attributes properly?

Thanks in advance.

It seems to think ‘imagePath’ is an Xml element, not an attribute. I’m not sure XmlContent supports having attributes in the root type, you may need to nest it one level deeper.

After playing around with it some more, that does seem to be the case. However I just ended up building my own content importer following the tutorial here, http://www.felsirworld.net/content-processors-in-monogame/, and the Dylan Wilson one.