More in this category:
using OrbCreationExtensions;
in your source code.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using SimpleJsonExtensions;
public class MyExporter {
public void ExportXml(Hashtable aHash) {
string xmlExportString = aHash.XmlString();
ExportToFile(xmlExportString, "SimpleXmlExport.xml");
}
private void ExportToFile(string exportString, string path) {
if(exportString == null || path == null) return;
if(Application.platform==RuntimePlatform.OSXPlayer ||
Application.platform==RuntimePlatform.WindowsPlayer &&
Application.platform!=RuntimePlatform.LinuxPlayer || Application.isEditor) {
// Put a proper prolog in the file
exportString = "\n" + exportString;
// We use UTF-8 encoding
byte[] bytes = new UTF8Encoding(true).GetBytes(exportString);
if(File.Exists(path)) File.Delete(path); // delete if it exists
FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
BinaryWriter w = new BinaryWriter(fs);
w.Write(bytes);
w.Close();
fs.Close();
}
}
}
{
level1: [
{
level2: Somevalue,
},
{
level2: Anothervalue,
},
],
}
Exported to XML:
Somevalue
Anothervalue
{
level1: [
{
level2a: Somevalue,
level2b: Anothervalue,
},
{
level2a: Yetanothervalue,
level2b: Runningoutofvalues,
},
],
}
{
level1: [
{
tag: level2,
level2a: Somevalue,
level2b: Anothervalue,
},
{
tag: level2,
level2a: Yetanothervalue,
level2b: Runningoutofvalues,
},
],
}
Exported to XML:
Somevalue
Anothervalue
Yetanothervalue
Runningoutofvalues