I\'m working with a team on a RPG engine in C# and XNA. We\'re planning on targeting Windows and Windows Phone 7, but are running into issues with AI interactions and contro
You could use an existing XML parser, there are a lot of different ways of doing it (SAX, StAX) and parsers available for many languages.
Then you could use XPath to reference nodes in your document.
You may also consider a library called XNA Debug Terminal at http://www.protohacks.net/xna_debug_terminal . This allows you to execute arbitrary c# statements at runtime. It basically works like an Eval() method for scripting languages. Maybe instead of making xml scripted actions, you can allow users to script actions on the fly while the game is running using this library? Or you can use it to script your own actions to see what happens in each case. One of the special terminal commands allows you to take a string that contains c# code and evaluate the code. So you could set up some preset actions and have the user choose from them. These ideas may not work for your particular case, but just thought I would give you (and anyone else reading this) some more options to think about.
You may wish to consider embedding a real language such as Lua instead of using an XML syntax. There's a reason why you don't see many programming languages built upon actual XML syntax! It's really awkward for actual programming tasks.
Do you necessarily need to interpret the scripts at runtime? You say your development is content driven, which is a good thing to do. But you don't necessarily need your scripts to be interpreted in order to take advantage of the increase in speed and efficiency from using XML or a scripting language.
I'm following Shawn Hargreaves' example of creating XML data and allowing the Content Pipeline to compile it into a .XNB. If you implement a scripting system or integrate an existing and make a ContentPipeline project for it, you can compile just the scripts that were added or modified, very little downtime between runs in comparison to recompiling the whole darn game.
And I definitely wouldn't go for XML, XNA may automatically have an importer for it, but it will be ugly as hell trying to use it. XNUA was supposed to be a lua library for XNA that's supposed to work well enough for this sort of thing.
Making designers compile to .XNB isn't all that different from the crap you have to do in engines like Source anyway.
Also, I found the following useful for thinking about scripted events:
Riverman Media - Object Oriented Programming, the Scripted Event System
Brandon Furtwangler - First Impressions Matter
XML Scripting!? Gasp! Now that is something that "could cause issues down the line"!
Why not just use C#? I hear it's pretty terrific. I've already given my opinion on this matter.
You need to ask yourself: Do your scripts really need to be data driven? Is there a reason that data can't be expressed using C#?
Do they really need to be interpreted at runtime? Because, if they really do, that can be done with C#.
And here's another answer of mine to an almost identical question, over on the gamedev.stackexchange.com. I've even put a little example of a possible implementation in there.
If you want to have actions that take more than a frame to execute (basically co-routines), for example: "Walk over here, Talk, Wait, Walk over there", you can implement this with yeild in C# reasonably well, too.
Edit: If you want to mix your XML levels, and C# script, here is an example of what I mean:
<Level>
<Door position="4,4" name="spookyDoor" />
<Region position="4,2" name="spookyOpener" />
</Level>
And in C#:
public void LevelStart()
{
this.Regions["spookyOpener"].OnPlayerEnter += () =>
{
(this.Items["spookyDoor"] as Door).Open();
};
}