Created
April 24, 2014 16:30
-
-
Save bcho/11260760 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <Shots xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | |
| <data> | |
| <value>0.59339682329791443</value> | |
| <value>0.27207647458921447</value> | |
| <value>0.68088770103595453</value> | |
| <value>0.37029365300876393</value> | |
| <value>0.22072801082432025</value> | |
| </data> | |
| <color> | |
| <value index="0" hexcode="#cb3f20" /> | |
| <value index="1" hexcode="#cb3f20" /> | |
| </color> | |
| </Shots> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Xml; | |
| using System.Xml.Serialization; | |
| using System.IO; | |
| namespace XMLTest | |
| { | |
| public class Shots | |
| { | |
| [XmlArrayAttribute("data")] | |
| [XmlArrayItemAttribute("value")] | |
| public double[] Data; | |
| [XmlArrayAttribute("color")] | |
| [XmlArrayItemAttribute("value")] | |
| public Color[] Colors; | |
| internal Shots() | |
| { | |
| } | |
| public Shots(int DataScale) | |
| { | |
| Data = new double[DataScale]; | |
| Random random = new Random(); | |
| for (int i = 0; i < DataScale; i++) | |
| { | |
| Data[i] = random.NextDouble(); | |
| } | |
| Colors = new Color[2]; | |
| for (int i = 0; i < 2; i++) | |
| { | |
| Colors[i] = new Color(i, "#cb3f20"); | |
| } | |
| } | |
| } | |
| public class Color | |
| { | |
| [XmlAttribute("index")] | |
| public int Index; | |
| [XmlAttribute("hexcode")] | |
| public string HexCode; | |
| internal Color() | |
| { | |
| } | |
| public Color(int index, string code) | |
| { | |
| Index = index; | |
| HexCode = code; | |
| } | |
| } | |
| public class XMLTest | |
| { | |
| public static void Main() | |
| { | |
| XmlSerializer serializer = new XmlSerializer(typeof(Shots)); | |
| TextWriter writer = new StreamWriter("test.xml"); | |
| Shots shot = new Shots(5); | |
| serializer.Serialize(writer, shot); | |
| writer.Close(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment