XML Question - Surprised I can't clarify the answer

Hi Guys,

Im looking at getting basic RTS Style unit data into Unity via XML.

This will include Weapons, Units and Unit Class.

The question I have and im surprised I can’t find the answer for is simply is it best to have one small xml file for each Unit/Class/Weapon or multiple Units/Weapons/Classes in 1 XML file?

Obviously the with the first option im going to have hundreds of small XML files but as each file will be associated to one particular item in the game it makes it very easy to manage.

but whats the ‘correct’ way?

Regards,

John

I’ve worked with XML files a few times under a professional setting, and many times while at school. In my opinion, I’ve found it best to have 1 XML file per type of data, and simply use identifier tags for each new node.

So for example, I would have something like:

blah gun1

etc…

And then just query the information from that one file for each node of data. This way, you can question information from the entire set using standard XML parsing (I’ve never done this from C#, but I’m guessing .NET has to have something for XML…), rather than having to build your own standards in order to query/compare/sort/etc. data from multiple files. One file will keep the data all in one place and query-able/comparable , rather than needing to use the OS’ directory system and your own custom code.

Hope this helps!

How are you generating the XML? For example, if you’re going to use a tool like articy:draft or MS Excel to edit the data, you’ll usually export everything as a single XML file. If you’re editing raw XML by hand, individual files might be easier to manage. Ultimately, you’ll spend more time creating and tweaking the XML data than writing the code to read it into your game, so let your data entry workflow dictate the choice.

We put every unit in it’s own file. All weapons are in a single file. All armor is in a single file. All damage types are in a single file. For us it’s really about the length of the data and the relationships between them. A weapon or armor can be used by more than one unit, etc.

The old Command and Conquer games held everything in one large INI file and it was, quite honestly, a nightmare.

Thanks for the replies.

I’m probably going to generate the XML by hand.

I was thinking pretty much along the lines of Kelso. - bit of both - Weapons in 1 XML, Unit Classes in 1 XML, Projectiles in one XML etc.

Ultimately, you’ll spend more time creating and tweaking the XML data than writing the code to read it into your game, so let your data entry workflow dictate the choice.

Im a noob at programming so this might not be so true,Im getting the hang of it but im doing some experimenting with data systems, something Ive neglected thus far, so we’ll see how we go :slight_smile:

Regards,

John