XML Scripting & Microsoft Office

Using Dark GDK.NET and C# has an advantage in that you have access to a number of XML commands natively, there’s a number of XML tutorials out there and it’s fairly easy to implement into Dark GDK.NET. I have my own parsers coded into my game project meant for parsing particular XML setups. Now, how would I use XML in a game project? On one hand I could have an abilities list and the other I could have all my level data stored into an XML database. The other bonus is that you can create open, modify and save XML documents in Microsoft Excel, which makes data entry a lot easier. I’ll demonstrate how this could work in relation to a game project.

I code a basic XML Template in Notepad++ (or C#)

image

Just have a few items to start with, at least 2 is enough, it just means Excel will automatically import it as a table for you.

Then we can import it as an XML into Excel, it’ll automatically create a schema for you as well.

image

Then you can just add more and more data and with ease. You can then export it.

It also works with slightly more complicated XML files, for example:

image

On the table it looks a little more confusing, but with the XML Source pane open you can select any directories within the XML Map. For example the ‘X’, ‘Y’ and ‘Z’ selected show up as the camera position. For something like my game, Abeyance, this works. However, this system is fairly limited, but it is a means of working a database into your game project, so it may not be the ideal method for setting up levels, but it’s certainly handy for a lot of other data. But as Abeyance scenes are small and aren’t very complex, this actually works.

Alternatively, if you have MS Access, you can create a table there and then export to .XML:

image

image

Then have your parser read the file generated by Access.

You could take Access to the next stage and actually create forms for adding your data.

image

And you’ll still be able to export the table as an XML file. This means XML databases for your games needn’t be such a drag.

Advertisements

11 comments

  1. Afraid I’ve never tried it. It looks like a decent DBP plugin though. However, not really touched DBP for a while now, as I am more interested in Dark GDK.NET these days, mainly because I have access to classes. Having XML in DBP through STYX would be a good way of implementing this at least. I suspect it’d be easy to make a parser for any XML files generated by Access or modified in Excel. When I’ve got my C# project transferred to my current laptop I may add a code snippet with an explanation of how it works, though it is fairly simple. 🙂

    Oh and I’ll prolly need to install Microsoft Office…I’ve still not caught up on installing all my apps onto my now repaired laptop. Literally, I only got around to getting Visual Studio 2012 installed this morning.

    • I see, I could not manage to get Excel to load in my file… just fails… can you email me a sample file and I can see where I went wrong?
      Finally, you got that thing back… they sure took their time…
      Yeah had a play with STYXs XML functions but I need to study it further, for now I am using INI files…

  2. Lol, I’ve had it back a lil’ while now. 😉 I’ve just been working is all and not properly sat down and installed everything yet,

    With Excel, copy the source code in the first image, at least right up until the tag ‘/ability’, well, if you may 2 entries of ‘ability’ Excel will automatically turn your imported data into a table. At least, it should work with Excel 2010, I don’t know about earlier versions.

    However, I find Access is actually a lot better tool for data entry when it comes to XML files, for one, it’s built for databases and two you can create your own forms to make data entry a lot more convenient and creating forms in Access is dead easy as it’s all point and click.

    • Ah, I guess I will have to wait for Office 2013 for Access then… I only got Home and Business 2010, but I tried the first Attributes part and it did not load correctly… can you confirm the code in full here?

  3. Ah, I was lucky, when I was student MS were offering Office 2007 Ultimate for £50 for students only with a free upgrade to 2010. I believe there’s a customer preview of 2013 available though. Might be tempted to upgrade when it comes out…depends on what it’s like. I use Office enough to be worth it. I am hoping there will be some Win 8 App versions, I like being able to dock my Win 8 apps.

    Anyway, I’ll post up the source when I’m online later.

      • Here. This is one generated by Microsoft Access, well, with the schema removed but you don’t have to use one.
        [edit]Replace [ & ] with > & <, because wordpress treats it as HTML, even with spaces.

        [?xml version="1.0" encoding="UTF-8"?]
        [Table1]
        [ID]1[/ID]
        [Name]Shotgun[/Name]
        [Description]Uses a scattershot[/Description]
        [Cost]300[/Cost]
        [Damage]50[/Damage]
        [/Table1]
        [Table1]
        [ID]2[/ID]
        [Name]Rocket Launcher[/Name]
        [Description]Fires a rocket[/Description]
        [Cost]2500[/Cost]
        [Damage]200[/Damage]
        [/Table1]

  4. Think I know the problem, Excel wants to load a schema, which is odd because I am 99.9% sure the example in this blog post didn’t have one. Though I am testing this on the 2013 preview version and the above was 2010. Access will generate a schema for you, but I’ve never made schemas by any other way.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s