Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Content Importer Exception XML element required

$
0
0

@Aurioch wrote:

Greetings

Sorry if I put this in the wrong place, I'm new here but has been using Monogame for long time actually, having started first in XNA. I have tried few other frameworks and engines, but I while I like and dislike various things, I always return to Monogame as I feel it offers me greatest control and the insight into my own code.

But anyway, to keep it short (and keep personal introduction in more appropriate place), I've been making a tactical RPG game and need to load my own map into it. This time, I have decided to use XNA/Monogame content importer for it instead of manually doing work (like before), and after writing my own level editor, preparing all code, adding new library and referencing it... I stumble upon this error in the content pipeline:

Importer 'XmlImporter' had unexpected failure!
Microsoft.Xna.Framework.Content.Pipeline.InvalidContentException: The Xml element 'TileSize' is required!

I don't know what to do, as class which is being deserialized to has the required element. I have tried to look around, but to no avail; I didn't manage to find anything useful about it; only a tutorial about having to write own content importer and an old bug submit for Monogame which was apparently solved.

To help, here's the class in question and the (stripped down to minimum) of the accompanying XML file:

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MortalRealmSilkWars
{
public class Level
{
public int TileSize
{
get { return tileSize; }
set { tileSize = value; }
}

    public List<List<Tile>> TileGrid
    {
        get { return tileGrid; }
        set { tileGrid = value; }
    }

    public Point StartPoint
    {
        get { return startPoint; }
        set { startPoint = value; }
    }

    public string MapName
    {
        get { return mapName; }
        set { mapName = value; }
    }

    int tileSize;
    Point startPoint;
    List<List<Tile>> tileGrid;
    string mapName;

    public Level()
    {

    }

    public Point GetTileLocation(Point coordinates)
    {
        Point result = new Point();

        result.X = (coordinates.X - startPoint.X) / tileSize;
        result.Y = (coordinates.Y - startPoint.Y) / tileSize;`

        return result;
    }
}

And XML (replaced <> with { })

{?xml version="1.0" encoding="utf-8"?}
{XnaContent}
{Asset Type="MortalRealmSilkWars.Level"}
{Level}
{TileSize}50{/TileSize}
{TileGrid}
{ArrayOfTile}
{Tile}
{Unwalkable}false{/Unwalkable}
{TileRectangle}
{Location}
{X}50{/X}
{Y}50{/Y}
{/Location}
{Size}
{Width}0{/Width}
0{/Height}
{/Size}
{X}50{/X}
{Y}50{/Y}
{Width}0{/Width}
{Height}0{/Height}
{/TileRectangle}
{TilePosition}
{X}50{/X}
{Y}50{/Y}
{/TilePosition}
{TileSpirits}
{Spirit}
{Name}Air{/Name}
{Amount}0.5{/Amount}
{/Spirit}
{Spirit}
{Name}Earth{/Name}
{Amount}0.5{/Amount}
{/Spirit}
{Spirit}
{Name}Light{/Name}
{Amount}0.5{/Amount}
{/Spirit}
{Spirit}
{Name}Heat{/Name}
{Amount}1{/Amount}
{/Spirit}
{/TileSpirits}
{TileItem}
{Name /}
{Amount}0{/Amount}
{/TileItem}
{/Tile}
{/ArrayOfTile}
{/TileGrid}
{StartPoint}
{X}60{/X}
{Y}60{/Y}
{/StartPoint}
{MapName}Test map{/MapName}
{/Level}
{/Asset}
{/XnaContent}

I have no idea what to do next, as class serializes into XML well and XML itself looks fine, so I need a big help.

Thank you in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles