XNA Creators Club Online
Page 1 of 1 (11 items)
Sort Posts: Previous Next

Help needed: XML structure format

Last post 05-12-2008 5:48 PM by c64days. 10 replies.
  • 05-09-2008 6:45 PM

    Help needed: XML structure format

    I'm trying hard to put my structure into xml for loading, but i fail to put a List of MyStruct in the xml fine, since i don't know the proper format and yet to find any good thorrow artical.


    mystruct:

        public class Level
    {
    //Level level = new Level();


    string SplashScreen;
    public string backgroundTexture;
    public List<Scene>storyBoard = new List<Scene>();

    public struct Scene
    {
    int NumOfSpaceshipsDown;
    String EnemySpaceShipModel;


    }

    ....
    }

    and my Xml file (one of many i've tried):

    <?xml version="1.0" encoding="utf-8" ?>
    <XnaContent>
    <!-- TODO: replace this Asset with your own XML asset data. -->
    <Asset Type="XmlLevelContent.Level">
       <backgroundTexture>backgroundTexture.png</backgroundTexture>
       <storyBoard>
           <Item>
             <NumOfSpaceshipsDown></NumOfSpaceshipsDown>
             <EnemySpaceShipModel>scout</EnemySpaceShipModel>
           </Item>
       </storyBoard>
    </Asset>
    </XnaContent>

    what is the problem, please help!



  • 05-09-2008 6:47 PM In reply to

    Re: Help needed: XML structure format

    You have to tell us what the problem is. Our goal is to try and help you find the solution.

    Are you getting an error? What error? Is the error when it is trying to build the project or run the project?


    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Metacreature Games | Super Gravelyn Bros | Bloc | Next-Gen
  • 05-10-2008 4:45 AM In reply to

    Re: Help needed: XML structure format

    Yes, i'm getting an serialization error, during to compile process.

    the error is: "Error    1    There was an error while deserializing intermediate XML. 'Element' is an invalid XmlNodeType. Line 8, position 8.    ..."

    thanks for your help.
  • 05-10-2008 12:01 PM In reply to

    Re: Help needed: XML structure format

    Your structure fields are private. You need to either make them public, or put a [ContentSerializer] attribute on them to explicitly mark them for inclusion in the XML.
    XNA Framework Developer - blog - homepage
  • 05-10-2008 12:22 PM In reply to

    Re: Help needed: XML structure format

    the structure is public, so isn't that make it's fields public as well? anyway, i only want the list of structure to be in the xml file not the structure it self. where i can find more info regarding those attributes?
  • 05-10-2008 1:48 PM In reply to

    Re: Help needed: XML structure format

    Fields are private unless you specify something different.

    From your example XML, it looks like you are expecting the fields NumOfSpaceshipsDown and EnemySpaceShipModel to be included in your XML file. That's not going to work if your fields are private.

    XNA Framework Developer - blog - homepage
  • 05-10-2008 3:50 PM In reply to

    Re: Help needed: XML structure format

    Can you directly to place where i can learn more about those attributes and how to use them? what exactly are those attributes? a compile level attributes? also a question relating to my previus thread: is there a way to point the asset to a custom one in which it's exist in the main game class/Path? anything i've tried failed.
  • 05-10-2008 8:30 PM In reply to

    Re: Help needed: XML structure format

    The ContentSerializerAttribute class is documented in the MSDN help. If you have specific questions about that documention, please ask them here: the more specific you can be about what you don't understand, the more likely that someone will be able to give you a useful answer.

    If you have suggestions on how the documentation could be improved, please file them on the Connect site. The only way we know what needs to be improved is if people tell us about it, and again, the more specific you can be, the more likely that we will be able to act usefully on your suggestion.

    I'm afraid I don't understand your second question.
    XNA Framework Developer - blog - homepage
  • 05-11-2008 11:08 AM In reply to

    Re: Help needed: XML structure format

    this is what i get if i check the help about ContentSerializationClass: "The following tables list the members exposed by the ContentProcessorAttribute type." i have to tell this is not much of a help to me, since until working with xna, i've never worked with c# before. the Therms of Serializations are new to me, but from reading at wikipedia i get it's the way to call to the process that take a data and build the format to store it. correct me if i'm wrong. also i don't know if the ContentSerializationClass is and xna or c# class, and how to use it?
  • 05-12-2008 1:24 PM In reply to

    Re: Help needed: XML structure format

    What 'ContentSerializationClass' are you talking about? I'm not familiar with any such class.

    Do you mean the ContentSerializerAttribute? That is an XNA Framework class used to control the Content Pipeline XML serializer.

    If that's the class you are asking about, please be more specific about what part of it you don't understand. Do you need help with how to use attributes in C#? Or do you know how to use attributes, but just can't figure out how this particular attribute works?
    XNA Framework Developer - blog - homepage
  • 05-12-2008 5:48 PM In reply to

    Re: Help needed: XML structure format

    All the attribute thing is new to me. i understand from your reply that the attributes are C# related, so i'll find some C# books and read to learn about it.

    thank you
Page 1 of 1 (11 items) Previous Next