Hi Y’all!
Whenever I try to fetch data from the xml I’m throw this error:
XmlException: Expected >, but found s
[115] Line 7, position 9.
Mono.Xml2.XmlTextReader.ExpectAfterWhitespace
(Char c)
Mono.Xml2.XmlTextReader.ReadEndTag ()
Mono.Xml2.XmlTextReader.ReadContent ()
Anyone got a clue whats going on?
Thanks!
item.xml:
<ItemCollection>
<Items>
<Item>
<Item name="r">
<Damage>32</Damage>
</Item>
</Items>
</ItemCollection>
ItemContainer.cs:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
[XmlRoot("ItemCollection")]
public class ItemContainer {
[XmlArray("Items")]
[XmlArrayItem("Item")]
public List<BaseItem> items = new List<BaseItem>();
public static ItemContainer Load(string path)
{
TextAsset _xml = Resources.Load(path) as TextAsset;
XmlSerializer serializer = new XmlSerializer(typeof(ItemContainer));
Debug.Log(_xml.text);
StringReader reader = new StringReader(_xml.text);
ItemContainer items = serializer.Deserialize(reader) as ItemContainer;
reader.Close();
return items;
}
}