xml
1<?xml version="1.0" encoding="UTF-8"?> 2<ArrayOfAnyType xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 <anyType xsi:type="array"> 4 <type1> 5 <string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string> 6 </type1> 7 <type2> 8 <string>yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy</string> 9 </type2> 10 </anyType> 11</ArrayOfAnyType>
C#
1 2前略... 3 4 public class array 5 { 6 public string[] type1; 7 public string[] type2; 8 9 public array() 10 { 11 type1 = new string[] { } 12 type2 = new string[] { } 13 } 14 15 public array(string[] t1, string[] t2) 16 { 17 type1 = t1; 18 type2 = t2; 19 } 20 } 21 22 public class MainClass 23 { 24 public static void Main(string[] args) 25 { 26 ArrayList arr = new ArrayList(); 27 arr.Add( 28 new array( 29 new string[] { "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, 30 new string[] { "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" } 31 ) 32 ); 33 34 Type[] et = new Type[] { typeof(array) }; 35 36 XmlSerializer serializer = new XmlSerializer(typeof(ArrayList), et); 37 StreamWriter stwrite = new StreamWriter(@"C:\sample.xml", false, new UTF8Encoding(false)); 38 serializer.Serialize(stwrite, arr); 39 stwrite.Close(); 40 } 41 }
array(string[], string[])のような配列をxmlに保存できたのですが、その保存されたxmlから元の状態に戻すにはどのように書いたらいいのでしょうか
xmlにするのに参考にしたサイトはこちらです。
http://dobon.net/vb/dotnet/file/xmlserializer2.html

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/02 08:33
2017/02/02 08:42
2017/02/02 08:50