Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Seperate and know the details the get from POST WWW server side

Discussion in 'Scripting' started by Dzxyan, May 16, 2014.

  1. Dzxyan

    Dzxyan

    Joined:
    Sep 23, 2013
    Posts:
    167
    say that i POST to get the from server side like this

    Code (csharp):
    1.  
    2. void Start()
    3.      {
    4.           string rawStringData = "<id>12343</id>";
    5.           byte[] rawData = System.Text.Encoding.UTF8.GetBytes(rawStringData.ToCharArray());
    6.  
    7.           WWW www = new WWW(url, rawData);
    8.           StartCoroutine(WaitForRequest(www));
    9.      }
    10.  
    11. public IEnumerator WaitForRequest(WWW www)
    12.     {
    13.         yield return www;
    14.  
    15.         //Check error
    16.         if (www.error == null)
    17.         {
    18.             Debug.Log("WWW Ok!: " + www.text);
    19.         }
    20.         else
    21.         {
    22.             Debug.Log("WWW Error: " + www.error);
    23.         }
    24.     }
    25.  
    26.  
    what i got from www.text is

    <id>12343</id><name>abcd</name><coin>123445</coin>

    how can i define each of information separate to get the information and let me put in the game?
    i wanna show the information after i get the details into the game interface.
    i just wanna know can i separate it?
     
  2. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    Last edited: May 16, 2014
  3. Dzxyan

    Dzxyan

    Joined:
    Sep 23, 2013
    Posts:
    167
  4. johnnydj

    johnnydj

    Joined:
    Apr 20, 2012
    Posts:
    211
    the return from the server is a big string.
    for example if you want to retrieve a top10 highscore players from a mysql database, you would have to use PHP, and PHP would do the selects, split it on separate lines and maybe parse it as a JSON format.
    then in unity you would read the JSON format and separate every value.