Question by
hikigaya0202 · May 02, 2017 at 01:15 PM ·
c#androidxmlxmlserializer
Loading xml on android . Tried and it Works in windows... Help ?
Just wanna ask what's wrong with my code I searched around the internet but nothings seems to work
This one got some positive comments about the answer but I just can't make it work :<
I didn't remove comments to let you see what trial and errors I have done to let you see what's wrong. Thanks :>
Here's my code
public Database_Element_list<T> Load<T,W>(string name)
{
TextAsset textAsset = (TextAsset)Resources.Load(name, typeof(TextAsset));
StringReader stringReader = new StringReader(textAsset.text);
XmlTextReader reader = new XmlTextReader(stringReader);
XmlSerializer serializer = new XmlSerializer(typeof(W));
//use to see xml in text
Text.text = textAsset.text;
return (Database_Element_list<T>)serializer.Deserialize(reader);
//Text.text = textAsset.text;
//FileStream stream = new FileStream(Application.dataPath + "/Scene/DatabaseFiles/" + name, FileMode.Open);
//var container = serializer.Deserialize(stream) as Database_Element_list<T>;
//stream.Close();
//Database_Element_list<T> container;
//XmlDocument xmldoc = new XmlDocument();
//xmldoc.LoadXml(textAsset.text);
//using (var stream = new MemoryStream(textAsset.bytes)) { return container = (Database_Element_list<T>)serializer.Deserialize(stream); }
}
Comment