Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by kUr4m4 · Apr 10, 2014 at 01:41 PM · c#iosxmlserializerdeserialization

XMLSerializer

I am trying to read/write an xml file to store some data for my game. Here is the object i am trying to store:

 public struct EndRaceData
 {
         // Data used to display section by section data
         public List<SpeedRecord> speedRecords { get; set; }
         // Data used for making a map
         public List<KeyValuePair<String,SpeedRecord>>recordsByname { get; set; }
         // Taken from Datatracker.instance
         public List<KeyValuePair<String,List<DataRecorder.GPSPoint>>> pointsPerChallenge { get; set; }
         // Taken from DataRecorder.instance
         public List<SpeedSegment> averageSpeeds { get; set; }
         // Taken from IPlayer..
         public float caloriesburnt { get; set; }
         // Taken from Datatracker.instance
         public float topSpeed { get; set; }
         // taken from Datatracker.instance
         public float points { get; set; }
         // taken from Datatracker.instance
         public string difficulty { get; set; }
         // taken from Datatracker.instance
         public float completedPercentage { get; set; }
         // challenge-specific data
         public int passedChallenges { get; set; }
         // Datatracker.instance
         public int failedChallenges { get; set; }
         // Datatracker.instance
         public int  fastChallengesPassed { get; set; }
         // Datatracker.instance
         public int slowChallengesPassed { get; set; }
         // Datatracker.instance
         public int keepChallengesPassed{ get; set; }
         // Datatracker.instance
         public string startTime { get; set; }
         // Datatracker.instance
         public string endTime   { get; set; }
 
 
         public float distanceTravelled { get; set; }
         
     public string filePath {get; set;}
 }

Where SpeedRecord is:

 public struct SpeedRecord
 {
         public float speed;
         public float distance;
         public string name;
         public string sectionStartTime, sectionEndTime;
 
         public SpeedRecord (string name, float speed, float distance, DateTime startTime, DateTime endTime)
         {
                 this.speed = speed;
                 this.name = name;
                 this.distance = distance;
                 this.sectionStartTime = startTime.ToString ();
                 this.sectionEndTime = endTime.ToString ();
         }
 
         public override string ToString ()
         {
                 return string.Format ("{0}\r\nAVG speed : {1} km/h\r\nDist : {2} m\r\nTime : {3} -> {4}\r\n", this.name, this.speed, this.distance, this.sectionStartTime, this.sectionEndTime);        
         }
 }

SpeedSegment is:

 public struct SpeedSegment
 {
         public float speed;
         public float time;
 }

and finally GPSPoint is:

 public struct GPSPoint
     {
             public float lat;
             public float lon;
             public float accuracy;
             public float time;
     
             public GPSPoint (float lat, float lon, float acc, float time)
             {
                     this.lat = lat;
                     this.lon = lon;
                     this.accuracy = acc;
                     this.time = time;
             }
     }

The issue I am having is that everything works perfectly on all platforms except for iOS. I can generate my XML files without any issues on all platforms, but when I try to read them on iOS, I get the following error:

XmlException: Document element did not appear. Line 1, position 1.

at Mono.Xml2.XmlTextReader.Read () [0x00000] in :0 at System.Xml.XmlTextReader.Read () [0x00000] in :0 at System.Xml.XmlReader.MoveToContent () [0x00000] in :0 at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot () [0x00000] in :0 at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.Serialization.XmlSerializationReader reader) [0x00000] in :0 Any suggestions as to what might be causing this? Im guessing it is something specific to iOS since the solution works fine on Android, Standalone and inside the editor.
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kUr4m4 · Apr 11, 2014 at 06:56 AM 0
Share

Anyone knows?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

XML Decentralization not working in Unity iOS build which working in Windows 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

System.Xml.XmlException: Root element is missing 1 Answer

Q about Building my game for so many devices 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges