Original Post
Hey all :) I have had a bit of a search around for this, but I haven't started developing anything yet, for the hope that there's an easier way. I'm using C#/Mono on Linux, but Mono is an almost full implementation of .NET, so suggest based on .NET. Don't ask why I'm using this platform: basically, it's the lesser of 4 evils that are valid platforms for a competition I'm entering. Basically what I want to do is read an XML element into an instance of a class, basically to get something like this:
<Particle>
<Lifetime>100</Lifetime>
<Sprite>smoke1.png</Sprite>
<DeltaSpeedMin>1</DeltaSpeedMin>
<DeltaSpeedMax>2</DeltaSpeedMax>
<DeltaAngleMin>0</DeltaAngleMin>
<DeltaAngleMax>0</DeltaAngleMax>
<InitialAlpha>1</InitialAlpha>
<DeltaAlphaMin>0</DeltaAlphaMin>
<DeltaAlphaMax>0</DeltaAlphaMax>
</Particle>
into this: public class Particle {
// these will be set at runtime, not constants
public double x;
public double y;
public double Speed;
public double Angle;
int Ticks;
// these will be read from XML
int Lifetime;
String Sprite;
double DeltaSpeedMin;
double DeltaSpeedMax;
double DeltaAngleMin;
double DeltaAngleMax;
double InitialAlpha; // 0..1
double DeltaAlphaMin;
double DeltaAlphaMax;
} Now, the obvious solution would be to use the .NET XML parser to get an XML node tree structure, then do manual assignments for each instance - but that seems like a poor solution, with every member added needing changes to the parser as well. I come from a perl background, so I would normally use an associative array rather than a fixed structure, which makes this kind of thing easy as anything - but for obvious reasons, that's much too slow when I'm processing so many particles per frame. I'm _hoping_ there's an easy way to do this, probably facilitated through the fact that .NET is bytecode and not fully compiled - does anyone have any tips?