-1

I am trying to read an xml file in Unity3D using this code

using (XmlReader xmlreader=XmlReader.Create("Assets\\config.xml")) 
{
    while (xmlreader.Read()) 
    {
        Debug.Log (xmlreader.Name.ToString());
    }
}

It prints all the names of the elements of the xml file except the last one. Because in the end it gives an invalid data exception. Why?

nix86
  • 2,837
  • 11
  • 36
  • 69
  • The date? It says invalid datA (not date). – nix86 Jul 21 '15 at 13:51
  • Ah apologies; I misread it. :) In that case, you'll need to start sharing some of this data and the code as it could be absolutely any reason. – David Arno Jul 21 '15 at 13:53
  • Agree with @DavidArno. You're going to have to dig in and get more information. That's a relatively generic exception. Explore its other properties, maybe there's more information there. Also take a look at the file in an editor that might tell you what's wrong (like Studio with Resharper installed). – James R. Jul 21 '15 at 13:55
  • Please delete this question as it serves no useful purpose to the wider community. – David Arno Jul 21 '15 at 17:38

1 Answers1

0

Problem solved!

I had to put this line

<?xml version="1.0" encoding="utf-16"?>

At the beginning of xml file.

nix86
  • 2,837
  • 11
  • 36
  • 69