Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

XMLSerializer

$
0
0
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 speedRecords { get; set; } // Data used for making a map public List>recordsByname { get; set; } // Taken from Datatracker.instance public List>> pointsPerChallenge { get; set; } // Taken from DataRecorder.instance public List 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.

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>