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 /
avatar image
0
Question by Florensie · Aug 18, 2015 at 01:19 PM · xmlparametersparsing

Help a noob parse an xml file

I didn't really want to put this here but I really don't understand all of this. I understand xml, but parsing it in C# is the problem. I searched on unity forums and answers but the almost all the solutions I found were either outdated or I didn't understood a single line of the code.

In my game I have a 5x5 grid, blue, green and grey blocks. The blocks are placed on the grid according to my xml file. This is an example of level 40: (0 means no block, 1 means a grey block, 2 means a blue block and 3 means a green block)

 <levels>
 <level id="40">
    <row id="1">
       <col id="1">1</col>
       <col id="2">0</col>
       <col id="3">0</col>
       <col id="4">0</col>
       <col id="5">3</col>
    </row>
    <row id="2">
       <col id="1">3</col>
       <col id="2">0</col>
       <col id="3">1</col>
       <col id="4">0</col>
       <col id="5">2</col>
    </row>
    <row id="3">
       <col id="1">2</col>
       <col id="2">0</col>
       <col id="3">0</col>
       <col id="4">1</col>
       <col id="5">0</col>
    </row>
    <row id="4">
       <col id="1">0</col>
       <col id="2">0</col>
       <col id="3">1</col>
       <col id="4">0</col>
       <col id="5">0</col>
    </row>
    <row id="5">
       <col id="1">0</col>
       <col id="2">1</col>
       <col id="3">0</col>
       <col id="4">0</col>
       <col id="5">0</col>
    </row>
 </level>
 </levels>

I will have a script that loops through the rows and columns given in the file to place the right blocks in the right place. But first I need to know how the script will select the right level and columns also with the id="" parameter. Making a loop shouldn't be that big of a problem for me but parsing the data is.

I really hope someone can help me on this. Thanks in advance.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by HarshadK · Aug 18, 2015 at 01:53 PM

Here's a tutorial on how it can be done: XML - Loading data from a xml file

Not much of an explanatory tutorial but the code from that page has logic and methods that you will require to parse your XML file.

Comment
Add comment · Show 1 · Share
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 Florensie · Aug 18, 2015 at 09:21 PM 0
Share

I'm still trying to get my head around it but I'll get it eventually. I'm probably better of learning it like this as well.

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

25 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

Related Questions

Handle HTML response 0 Answers

Parseing Varible names from strings 1 Answer

Retrive value from xml 1 Answer

Parse xml with unknown fields 1 Answer

Parsing an XML file periodically 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