Code:
//Example code to show the
// error caused by loading a xml document with attributes.
public class SpikeTest : MonoBehaviour
{
public const string DefaultString1 =
@"<NodeOne><NodeTwo/></NodeOne>";
public const string DefaultString2 =
@"<NodeOne><NodeTwo attr='hello'/></NodeOne>";
// Use this for initialization
void Start ()
{
using(var responseReader = new StringReader(DefaultString1))
{
using(var xmlReader = new XmlTextReader(responseReader))
{
var xmlOutcome = new XmlDocument();
xmlOutcome.Load(xmlReader);
var item = xmlOutcome.GetElementsByTagName("NodeTwo");
Debug.Log("NodeTwo first: " + item[0].LocalName);
}
}
using(var responseReader = new StringReader(DefaultString2))
{
using(var xmlReader = new XmlTextReader(responseReader))
{
var xmlOutcome = new XmlDocument();
// Fails here
xmlOutcome.Load(xmlReader);
var item = xmlOutcome.GetElementsByTagName("NodeTwo");
Debug.Log("NodeTwo second: " + item[0].LocalName);
}
}
}
}
The above code works only for DefaultString1 when built on the WebGL platform. The code works fine in the Editor but fails on the second load. Looks like adding attributes is what causes the error. This happens only when exceptions are disabled. On Enabling the exceptions no errors are thrown and the code executes fine.