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 Scrawny · Oct 03, 2018 at 12:15 PM · xmlxmlserializermultidimensional arrayexcelmultidimensional

Columns in XML serialization

I have a string[][] array that I serialize into an XML file, but it all gets plopped into a single column, despite the 2D nature of the array. The serializer seems to at least partially understand 2D arrays because the order the data is in the XML file has the data from the arrays one row at a time, though I might be misunderstanding how the array gets parsed

How should I go about changing the structure of my serialized XML file, or can this be achieved automatically using some sneaky part of the serializer that I didn't manage to find? Bonus points if it's possible to add little headers for each column or row

 public static void SaveData_AsXML(string[][] _data)
 {
     XmlSerializer _serializer = new XmlSerializer(typeof(string[][]));
     FileStream _stream = new FileStream(Path.Combine(dataPath, fileName), FileMode.Create);
     _serializer.Serialize(_stream, _data);
 }


Result (two items in the array, starting at lines 2 and 7): alt text

example.jpg (32.2 kB)
Comment
Add comment · Show 1
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 Bunny83 · Oct 15, 2018 at 01:30 PM 0
Share

Uhm, have you actually looked at the generated xml data? X$$anonymous$$L represents structured and named data. There is no real concept of an "array" in X$$anonymous$$L. X$$anonymous$$L consists of data nodes (elements) which can be structured any way you want. Single arrays generally get serialized into a root node and several nested nodes for the elements. However jagged arrays are usually serialized into a root node, several nested nodes (one for each outer array element) and each of those nested nodes get the actual elements (of the inner arrays) as nested elements. However There are no names available for the different elements needed.


Finally how do you actually convert your X$$anonymous$$L into a spread sheet? I guess the serialization to X$$anonymous$$L actually works but your importing into a spreadsheed does not. There's no generally valid way how X$$anonymous$$L data should be interpreted without a DTD or XSD.


Your data is just a chunk of strings. So adding any sort of headers or na$$anonymous$$g is pretty impossible without creating proper data classes which represents your data in a structured way.


It's still not clear what you're trying to achieve here. Where does the data come from and what should it look like in the end? Why serialize to X$$anonymous$$L if you see$$anonymous$$gly want the data in a spreadsheet? Wouldn't "CSV" make more sense?

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

91 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 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

How to type Color32 format into XML? 1 Answer

Why am I geting null reference exception while reading xml file? 0 Answers

Parse XML file in Unity C# 2 Answers

Create a lighter/darker color based on a OpenXml color 1 Answer

Error while deserializing an xml file 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