Mcguirk's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
4 (0.01 per day)
Joined:
01-April 12
Profile Views:
68
Last Active:
User is offline Apr 05 2012 07:38 AM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   Mcguirk has not set their status

Posts I've Made

  1. In Topic: Serializing Array into XML

    Posted 4 Apr 2012

    Hi Ntwiles,
    When dealing with arrays, the default XML serializer expects you to use <Item> tags for each element of the array, not the the array type (char in your case).

    Try this XML:

    <?xml version="1.0" encoding="utf-8" ?>
    <XnaContent>
      <Asset Type="SharedContent.Level">
        <map>
          <Item>13</Item>
        </map>
      </Asset>
    </XnaContent>
    
    
  2. In Topic: XML content pipeline to load array of objects with different subtypes

    Posted 3 Apr 2012

    Hi Daniel,
    I did not use any extension libraries or custom importers/processors. I just added the xml file to the Content Library using all the default stuff. As for getting the serializer to recognize your custom types, you probably need to add a namespace qualifier to the start of your type names. Something like this:

    namespace MyNameSpace
    {
        public class MySubClass0 : MyBaseClass
        {
            public int MySubData0;
        }
    }
    
    

        <Item Type="MyNameSpace.MySubClass0">
    
    
  3. In Topic: XML content pipeline to load array of objects with different subtypes

    Posted 1 Apr 2012

    I dug into it a bit more and managed to answer my own question. I hand created an instance of my object array and then followed the instructions in this article to write the array to an xml file: http://msdn.microsof...y/ff604982.aspx

    Looking at the output, it appears I needed a Type attribute on each Item node to specify the type. So my modified XML file looks like this:

    <XnaContent>
        <Asset Type="MyBaseClass[]">
            <Item Type="MySubClass0"> 
                <MyBaseData>alpha</MyBaseData>
                <MySubData0>314</MySubData0>
            </Item>
            <Item Type="MySubClass1">
                <MyBaseData>bravo</MyBaseData>
                <MySubData1>true</MySubData1>
            </Item>
        </Asset>
    </XnaContent>
    
    

My Information

Member Title:
New D.I.C Head
Age:
35 years old
Birthday:
March 4, 1978
Gender:
Location:
Edmonton, AB
Years Programming:
20
Programming Languages:
C, C++, C#, Java

Contact Information

E-mail:
Click here to e-mail me

Friends

Mcguirk hasn't added any friends yet.

Comments

Mcguirk has no profile comments yet. Why not say hello?