Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are just wanting to load in XML without manipulating the data at all, you can just use the built in XNA Content Serializer.</p> <p>Essentially you define a class which maps to your xml format, and then read the XML into an instance of that class.</p> <p>For example. Here I define the class I want to load into:</p> <p><a href="http://code.google.com/p/mbhxnazombietaxi/source/browse/trunk/ZombieTaxi/MBHEngineContentDefs/Behaviour/SpriteRenderDefinition.cs" rel="nofollow">SpriteRenderDefinition.cs</a></p> <p>I chose this one because it has nested classes like the case you describe. Note that it goes into the ContentDefinitions project of you XNA solution.</p> <p>Now here is the xml file that fills in the content of a SpriteRenderDefinition:</p> <p><a href="http://code.google.com/p/mbhxnazombietaxi/source/browse/trunk/ZombieTaxi/ZombieTaxi/ZombieTaxiContent/GameObjects/Characters/Civilian/Behaviours/Sprite.xml" rel="nofollow">Sprite.xml</a></p> <p>The format of that XML maps directly to the member names of SpriteRenderDefinition.</p> <p>And finally, the code to actually load that XML data into an actual Object at runtime is very straight forward:</p> <pre><code>SpriteRenderDefinition def = GameObjectManager.pInstance.pContentManager.Load&lt;SpriteRenderDefinition&gt;(fileName); </code></pre> <p>After calling that line, you have a SpriteRenderDefintion object populated with all the content of the XML file! That is all the code I wrote. Everything else is built into XNA. It's really quite slick and useful if you take an hour or so to figure it out!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload