I'm writing a level editor in which you can position entities (models) and the control points of Bezier curves. I'm trying to write the data to an XML file which can then be loaded through the Content Pipeline. However, I can't get it to work with the layout I have and I can't seem to make one that works.
The layout of the class is as follows, with variable name followed by type
LevelData (custom class)
- beziers (BezierInfo class)
- inner (List of Vector3)
- outer (List of Vector3)
- entities (List of EntityInfo class)
- type (String)
- ModelName (String)
- position (Vector3)
This is the XML file I've created to try and get a working file for the content pipeline
| <?xml version="1.0" encoding="UTF-8"?> |
| <XnaContent> |
| <Asset Type="DataTypes.LevelData"> |
| <!--Bezier Pairs Info--> |
| <beziers Type="System.Collections.Generic.List[DataTypes.BezierPairsInfo]"> |
| <Item> |
| <!--Inner Curve--> |
| <inner Type="System.Collections.Generic.List[Microsoft.Xna.Framework.Vector3]"> |
| <Item> |
| <X>8</X> |
| <Y>0</Y> |
| <Z>8</Z> |
| </Item> |
| <Item> |
| <X>5</X> |
| <Y>2</Y> |
| <Z>1</Z> |
| </Item> |
| <Item> |
| <X>-12</X> |
| <Y>0</Y> |
| <Z>4</Z> |
| </Item> |
| </inner> |
| <!--Outer Curve--> |
| <outer Type="System.Collections.Generic.List[Microsoft.Xna.Framework.Vector3]"> |
| <Item> |
| <X>13</X> |
| <Y>1</Y> |
| <Z>5</Z> |
| </Item> |
| <Item> |
| <X>7</X> |
| <Y>2</Y> |
| <Z>-4</Z> |
| </Item> |
| <Item> |
| <X>-13</X> |
| <Y>0</Y> |
| <Z>-2</Z> |
| </Item> |
| </outer> |
| </Item> |
| </beziers> |
| <!--Entity Info--> |
| <!--<Asset Type="DataTypes.EntityInfo[]">--> |
| <entities> |
| <Item> |
| <type>STATIC</type> |
| <modelName>Level\level_complete</modelName> |
| <Asset Type="Microsoft.Xna.Framework.Vector3"> |
| <X>0</X> |
| <Y>0</Y> |
| <Z>0</Z> |
| </Asset> |
| </Item> |
| <Item> |
| <type>STATIC</type> |
| <modelName>Models\tree_cave_only</modelName> |
| <Asset Type="Microsoft.Xna.Framework.Vector3"> |
| <X>20.1941</X> |
| <Y>0</Y> |
| <Z>20.23614</Z> |
| </Asset> |
| </Item> |
| </entities> |
| </Asset> |
| </XnaContent> |
Ignore from <entities> downwards - I haven't gotten that far yet.
This is the C# code to go along with it - the XML file is trying to save the data from an instance of LevelData
| using System; |
| using Microsoft.Xna.Framework; |
| using System.Collections.Generic; |
| |
| namespace DataTypes |
| { |
| // information from entities |
| public struct EntityInfo |
| { |
| public String type; |
| public String modelName; |
| public Vector3 position; |
| } |
| |
| // information from pairs of Bezier curves |
| public struct BezierPairsInfo |
| { |
| public List<Vector3> inner; |
| public List<Vector3> outer; |
| } |
| |
| // level data shoved in a handy dandy place |
| public class LevelData |
| { |
| //public float versionNumber; |
| //public BezierPairsInfo[] beziers; |
| //public EntityInfo[] entities; |
| public List<BezierPairsInfo> beziers; |
| public List<EntityInfo> entities; |
| } |
| } |
And this is the error I get when trying to compile the project with the XML file in Content
Error 1 There was an error while deserializing intermediate XML. 'Element' is an invalid XmlNodeType. Line 9, position 12. C:\Users\Iki\Desktop\SVN\BG\trunk\Boogey-Editor\Editor\Content\levelFile.xml 9 12 Editor
Any ideas? I'm guessing it's the list within a list, since the error is at the second Item tag.