Question by
sillanstudios · Mar 17, 2016 at 04:50 PM ·
serializationxmlxmlserializer
Read XML file and assign value to variables
Hey Guys, I really need help with the following: I want to read an XML file of data and assign values in the xml file to variables in a C# Script. Here's an example of the XML...
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="luas_stops" id="luas_stops">
<SimpleField name="StopID" type="int"></SimpleField>
<SimpleField name="Abbreviation" type="string"></SimpleField>
<SimpleField name="LineID" type="int"></SimpleField>
<SimpleField name="SortOrder" type="int"></SimpleField>
<SimpleField name="IsEnabled" type="int"></SimpleField>
<SimpleField name="IsParkAndRide" type="int"></SimpleField>
<SimpleField name="IsCycleAndRide" type="int"></SimpleField>
<SimpleField name="ZoneCountA" type="int"></SimpleField>
<SimpleField name="ZoneCountB" type="int"></SimpleField>
<SimpleField name="Latitude" type="float"></SimpleField>
<SimpleField name="Longitude" type="float"></SimpleField>
<SimpleField name="IrishName" type="string"></SimpleField>
</Schema>
<Folder><name>luas_stops</name>
<Placemark>
<name>Tallaght</name>
<ExtendedData><SchemaData schemaUrl="#luas_stops">
<SimpleData name="StopID">1</SimpleData>
<SimpleData name="Abbreviation">TAL</SimpleData>
<SimpleData name="LineID">1</SimpleData>
<SimpleData name="SortOrder">260</SimpleData>
<SimpleData name="IsEnabled">1</SimpleData>
<SimpleData name="IsParkAndRide">1</SimpleData>
<SimpleData name="IsCycleAndRide">1</SimpleData>
<SimpleData name="ZoneCountA">4</SimpleData>
<SimpleData name="ZoneCountB">4</SimpleData>
<SimpleData name="Latitude">53.2874944444444</SimpleData>
<SimpleData name="Longitude">-6.37458888888889</SimpleData>
<SimpleData name="IrishName">Tamhlacht</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>-6.37458888888889,53.287494444444398</coordinates></Point>
</Placemark>
<Placemark>
<name>Hospital</name>
<ExtendedData><SchemaData schemaUrl="#luas_stops">
<SimpleData name="StopID">2</SimpleData>
<SimpleData name="Abbreviation">HOS</SimpleData>
<SimpleData name="LineID">1</SimpleData>
<SimpleData name="SortOrder">250</SimpleData>
<SimpleData name="IsEnabled">1</SimpleData>
<SimpleData name="IsParkAndRide">0</SimpleData>
<SimpleData name="IsCycleAndRide">0</SimpleData>
<SimpleData name="ZoneCountA">4</SimpleData>
<SimpleData name="ZoneCountB">4</SimpleData>
<SimpleData name="Latitude">53.2893694444444</SimpleData>
<SimpleData name="Longitude">-6.37885</SimpleData>
<SimpleData name="IrishName">Ospidéal Thamhlachta</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>-6.37885,53.289369444444397</coordinates></Point>
</Placemark>
I just want to be able to extract and display some of these values in my game's UI. Also I want to maybe store the Latitude and Longitude fields in an Array so I can do things with them later. Would really appreciate an help I can get e.g. a script which will do something like that. Thanks!
Comment