parsing xml with webplayer

	var  xmlData = new XmlDocument();
	var content : XmlNodeList;
	var contentList : XmlNodeList;
	

    xmlData.Load("http://www.myurl.com/" + PlayerPrefs.GetString("User") + "/" + file);
    //yield xmlData;  I tried to put this in to see if it helps, it didn't
    lastDebug = "http://www.myurl.com/" + PlayerPrefs.GetString("User") + "/" + file;
    
    contentList = xmlData.GetElementsByTagName("TAGHERE");

So I have been reading xml from a file on a site. This works great in the editor build, but once I make the webplayer it doesn’t work. I have done some tests and it appears to be reading in no data.

How do you the error from xmlData.Load to see what is happening. I have no idea why it won’t work on the web build and really want to get this fixed ASAP, any help would be appreciated.

I just made a standalone build and tested it, works great. Sigh…

Seems webplayer doesn’t have system.xml, how can include that?

Any clues on this? I still can’t get it to work.

Hi there!
I think, that loading by url won’t work in Unity. Try to load xml-data from url via WWW instead of xmlData.Load(), and after this load it to XmlDocument with xmlData.Load(xmlString) method.
Something like this [pseudocode]:

var url = "http://www.myurl.com/" + PlayerPrefs.GetString("User") + "/" + file;
WWW call = WWW(url);

while(!call.isDone)
{
    yield return WaitForSecond(0.5f);
}

var  xmlData = new XmlDocument();
xmlData.Load(call.text);
contentList = xmlData.GetElementsByTagName("TAGHERE");

UPD: Also your server shoud have crossdomain.xml file, read more here: http://docs.unity3d.com/Documentation/Manual/SecuritySandbox.html

I have done the cross domain, I ran into that problem earlier in the development accessing this different php scripts.

I tried that and XmlDocument wouldn’t accept that string. I am pretty sure the problem is that isn’t included in the webplayer. I don’t know if there is a different option for loading the file…

I googled a lot without finding a solution however I found one. So I thought I would post so others can see

You need to read in as Patico suggested, however you can’t just give it the text, you have to use StringReader to give it a format xmlData.Load can use like so

xmlData.Load(new StringReader([url]www.text));