Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • XML Parsing in Unity

    • 0
    • 2
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.60k
    Comment on it

    Hello Readers


    Today I am going to explain you parsing of XML in unity. XML can be parse in unity by two ways.

    1.       By Class method.

    2.       By Normal method.


    Let’s discuss both these one by one.

    1.       By Class Method:-  First of all, create a XML file and put all your fields in that. Like shown below:-

    <?xml version="1.0" encoding="utf-8"?>
    <LevelData xmlns:xsi="" xmlns:xsd="">
    <Color>1</ Color >


    Save this as an XML file.


    Now you need to create a class in with same name “LevelData” in the unity as shown below:-


    using UnityEngine;
    using System.Collections;
    using System.Xml.Serialization;
    using System.Collections.Generic;
    using System;
    public class LevelData : MonoBehaviour
                    public int LevelNumber;
                   public int Color;


    Now create one more class to read the data as shown below:-

    void Start()
            string path = Path.Combine(Application.dataPath, "Resources/XMLNAME.xml");
            LevelData data = XmlUtil<LevelData>.LoadDataFromXmlAsset<LevelData>(path);

    This is how you can ready data. 

    Keep coding.  

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: