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
0
Question by VeTaL · Aug 26, 2013 at 02:31 PM · xmlparsingtiled

Parse xml with unknown fields

I'm working on Tiled parser to Unity. In Tiled, it is possibble to add objects to the level (they are stored in xml format). I'm looking for a possibility to add any property to the object, so it can be read and used in Unity.

For example, i'm adding object with name Apple, script would search for Apple prefab (easy part) and create it. Next, i can add some fields and values in Tiled. What i'm looking for is a way how to parse and send them to Unity prefab. Say, i can agree that prefab should have the same name as main script (so far so good).

Actually, it is a process of deserializing object from xml.

PS: just during writing of this question, i got an idea that i can inherit all parsable prefabs script components from some base class, and use its method for sending parsed fields. But the main part of the question is still there: how to parse unknown xml?

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
0
Best Answer

Answer by perchik · Aug 26, 2013 at 02:40 PM

Simply put--- you can't. If you know absolutely nothing about the XML there is no way to parse it.

Now, with that said, it sounds like the XML is being generated with some format. Perhaps something like

 <Object name>
    <property 1>
    <property 2>
 </object name>
 <Object name>
    <property 1>
 </object name>

in which case, you may not know exactly how many properties it has, but it has some fixed format. I'd suggest trying to figure out what that format is and which pieces are optional. Then parse that general format.

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 VeTaL · Aug 26, 2013 at 02:58 PM 0
Share

Well, i know the whole structure of xaml. I don't know how to send those properties to custom script component.

Say, i'm adding object with name "door", set property "Id" to "101" and "Description" to "Just a common door".

   <object name="door" type="first" gid="1" x="1664" y="1408">
    <properties>
     <property name="Description" value="Just a common door"/>
     <property name="Id" value="101"/>
    </properties>
   </object>

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

16 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

Related Questions

A node in a childnode? 1 Answer

XML parsing c# in unity 1 Answer

JSON vs XML for Unity C# 1 Answer

Handle HTML response 0 Answers

Best practice to store and load a specific set of objects? 3 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