When i load and run XMl from the unity platform it works fine and take the input from the XMl file loaded on the server…But when i try to access it from the WEBplayer it doesw not take the input …My script of parsing is…
public static double accum;
public static int[] Values=new int[3];
IEnumerator Start()
{
WWW www =new WWW("http://link/new.xml");
//Load the data and yield (wait) till it's ready before we continue the rest of this method.
yield return www;
if(www.error== null)
{
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.LoadXml(www.text);
XmlNodeList xnlist1=xmlDoc.SelectNodes("/spheres/sphere1/score");
XmlNodeList xnlist2=xmlDoc.SelectNodes("/spheres/sphere2/score");
XmlNodeList xnlist3=xmlDoc.SelectNodes("/spheres/sphere3/score");
foreach(XmlNode xn1 in xnlist1)
{
Values[0]=int.Parse(xn1.InnerText);
}
foreach(XmlNode xn2 in xnlist2)
{
Values[1]=int.Parse(xn2.InnerText);
}
foreach(XmlNode xn3 in xnlist3)
{
Values[2]=int.Parse(xn3.InnerText);
}
}
Debug.Log(Values[0]);
Debug.Log(Values[1]);
Debug.Log(Values[2]);
accum=Convert.ToDouble(Values[0]+Values[1]+Values[2])/3;
I have same problem.
Remove “System.Xml” from plugins folder Or from Assets.
I have “System.Xml” in my Plugins folder, it works well when i run in UnityEditor, but not in another platform, so i just removed dll and then reopen unity&Mono , it works well.
Hope it’ll work for you.
Below is code for xml parsing which i have used, i think , it’ll help you.
using UnityEngine;
using System.Collections;
using System;
using System.Xml;
using System.Xml.Serialization;
public class XmlParsing : MonoBehaviour
{
public string url;
private XmlNodeList categories;
private XmlNodeList products;
public static bool isParseFinished;
void Awake()
{
isParseFinished = false;
}
IEnumerator Start ()
{
//Load XML data from a URL
url = "http:/......";
WWW www = new WWW (url);
//Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
yield return www;
if (www.error == null) {
//Sucessfully loaded the XML
Debug.Log ("Loaded following XML " + www.data);
//Create a new XML document out of the loaded data
XmlDocument xmlDoc = new XmlDocument ();
xmlDoc.LoadXml (www.data);
XmlNodeList elemList = xmlDoc.GetElementsByTagName("category");
for (int i = 0; i < elemList.Count; i++)
//for (int i = 0; i < 1; i++)
{
Debug.Log(elemList*.SelectSingleNode("id").InnerText);*
_ Debug.Log(elemList*.SelectSingleNode(“name”).InnerText);*_
* }*
* isParseFinished = true;*
* } else {*
* Debug.Log ("ERROR: " + www.error);*
* }*
* }*
}