Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
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
Add comment
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

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

53 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Please explain me Saving / Loading data logic (Serialization) 1 Answer

Random XML Questions Using Fisher-Yates Shuffle 0 Answers

xml file read as MonsterCollection.cs 0 Answers

Unity game doesn't work after binding 0 Answers

How to save Slider fill area in Xml? 0 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