I have data from SQL database that contains xml text which are being echoed with php script
For example this:
No:1|TestName:MachineAlfonso|TestParameter:< asdf/>|TestConnection:1234;
This data is later being parsed to Unity for later uses.
however when i try to print it in unity, It somehow converting the < to < ; and the > to > ;
The full output become
No:1|TestName:MachineAlfonso|TestParameter:< ; asdf/> ;|TestConnection:1234;
Is there any function to print the output to become a human readable sign not as html code? because those two signs( < and >) are just some than many other html simple that i want to convert.
this is the C# script i use to print the echoed data
public IEnumerator RefreshData()
{
//load the data
//dataLoader is the link of the echoed php data
WWW InventoryDatabase = new WWW(dataLoaderURL);
//wait until its done dowloading
yield return InventoryDatabase;
string abc = InventoryDatabase.text;
Debug.Log("text is: " + abc);
}
Try PHP's htmlentities()
function. It's designed specifically for this purpose:
See more: http://php.net/manual/en/function.htmlentities.php
In the end, in order not to waste time, I just use replace like @derHugo has suggested.
Hopefully there are better and cleaner ways to do it. But hey, its a start. ^_^
Here is the code snippets if someone has similar problem:
public IEnumerator RefreshData()
{
//load the data
//dataLoader is the link of the echoed php data
WWW InventoryDatabase = new WWW(dataLoaderURL);
//wait until its done dowloading
yield return InventoryDatabase;
string temp = InventoryDatabase.text;
temp = temp.Replace("<", "asdf");
temp = temp.Replace(">", "<");
temp = temp.Replace("&", "&");
temp = temp.Replace(""", "\"");
//this "Inventory" contains all the data from the echoed file
string Inventory = temp;
string abc = InventoryDatabase.text;
Debug.Log("text is: " + Inventory);
}