|
Hi, I'm trying to create a XMLHelper class for my game where I want to save and load XML's files from my server. I would like to know how to upload and download this XMLs from there. Thanks for all!
(comments are locked)
|
|
Grabbing and sending XML data to and from a server can be done with the WWW class to call scripts on your server. Since XML is just text, you can use the basic WWW functions to call a URL, and read the 'WWW.data' variable to get your XML. EG:
Similarly, you can use the WWWForm class to POST some XML data as a string to a script on your server. Assuming "myXMLString" contains the XML data that you want to post to your server, you could use this:
As for actually parsing and manipulating the XML data once you have it in Unity, you'll need to use the .net System.Xml classes and functions. Because this is part of .net, and not specific to Unity, you can find out more by doing general searches for how to use XML in .net. The examples will be c#, but the API is exactly the same if you're using Javascript in Unity.
(comments are locked)
|
|
To download your XML files, just use
and then use www.data or www.bytes, to access the data, which you can then process as XML (for example using the .NET Xml classes). Uploading data (if you want to use http) works the same way, there's a version of the WWW constructor which takes data to upload as a second parameter:
(comments are locked)
|
