Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
UnityGamesRoland

Reading data from an .xml file?

Question

Ok so in short, I'm working on a standalone database like app for a WarZ emulator.

I have the game's database, all I want is to create a class in unity which stores the item's name and some corresponding stats. (Damage, Recoil, etc...)

 

I've just started looking into some tutorials, but I feel like I won't figure this out in a day so I'll just pre-post this question.

Here is a snippet of the db: Please login or register to see this link.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Rather than just XML parsing, I'd use XML Serialization.

Parsing is where your code takes each variable and writes it to the XML file for writing. And it goes through each line of the XML file, where your code can convert it back to a variable for reading.

In your case Serialization would be much simpler. Instead of going through each variable, you just provide an XML Serializer with the instance of the class. It generates the XML file where all the values of variables within the class are stored (if they are labelled with the right attributes). Serialization and Deserialization (xml -> class, and class -> xml) can each be done in a single line.

 

This is one method which uses System.Xml.Serialization as the XML Serializer (there are others available).

Please login or register to see this link.

 

I'd normally use JSON instead of XML. There is a great JSON Serializer on the Asset Store:

Please login or register to see this link.

Edited by randomrabbit

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...