how can i parse xml through API in unity please can anyone explain with some example.

I am trying to parse an XML through API . XML is loading but unable to read nodes of the xml, please can anyone help me with some suitable example from which i can read nodes of my XML and display in GUI.

Thanks in advance

Import System.xml.dll in “Assets/Plugins” folder.

By the way, xmlDll is too big somtime.

[1] may be a better choice.


Hi Guys i got the solution and i am shring with you all for reference…

using System.Collections;
using UnityEngine;
using System.Xml.Serialization;
using System.Xml;
using System.Collections.Generic;
using System.IO;
using System;

public class newLoad : MonoBehaviour {

private string _url = "your API or url of xml";

private string _xml;
Vector2 scrollPosition =;
XmlDocument xmlDoc = new XmlDocument();
List<Dictionary<string,string>> levels = new List<Dictionary<string,string>>();
Dictionary<string,string> obj;
ArrayList listItems = new ArrayList();

IEnumerator Start() {

     // Start a download of the given URL

    WWW www = new WWW(_url);

    // Wait for download to complete

	yield return www;
    // get text

    _xml = www.text;

	XmlDocument xmlDoc = new XmlDocument();


    // having XML here. Do with it whatever you want...
	XmlNodeList levelsList = xmlDoc.GetElementsByTagName("MainCategories");
	foreach (XmlNode levelInfo in levelsList)
		//Debug.Log("foreach inner");
		string str = levelInfo.InnerXml;
		XmlNodeList levelcontent = levelInfo.ChildNodes;
		obj = new Dictionary<string,string>();
	//	Debug.Log("MainCategories = " + str);
		foreach (XmlNode levelsItens in levelcontent)
			//Debug.Log("~~~~~~First Node~~~~~");
			Dictionary<string,string> obj1 = new Dictionary<string,string>();
			if(levelsItens.Name == "MainCategory")
				//Debug.Log("~~~~~~Second Node~~~~~");
				string str1 = levelsItens.Name;
			//	Debug.Log("MainCategory = " + str1);
				foreach (XmlNode levelsItens1 in levelsItens)
					//Debug.Log("~~~~~~Third Node~~~~~");						
					Dictionary<string,string> obj2 = new Dictionary<string,string>();
					if(levelsItens1.Name == "MainCategoryID")
						string str2 = levelsItens1.InnerXml;
						Debug.Log("MainCategoryID = " + str2);
					if(levelsItens1.Name == "MainCategoryTitle")
						string str3 = levelsItens1.InnerXml;
						Debug.Log("MainCategoryTitle = " + str3);
						if(str3 != "NULL"){

void OnGUI () {
   GUILayout.BeginArea(new Rect(0f, 0f, 300f, 200f),;
   scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true); 

   foreach (string item in listItems)
     GUILayout.Label(item,, GUILayout.ExpandWidth(true));