怎么读plist文件
<plist>
<dict>
<key>frames</key>
<dict>
<key>n1.png</key>
<dict>
<key>frame</key>
<string>{{0,0},{122,236}}</string>
<key>offset</key>
<string>{-15,7}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{124,75},{122,236}}</string>
<key>sourceSize</key>
<string>{400,400}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>test1.png</string>
<key>size</key>
<string>{1024,1024}</string>
<key>textureFileName</key>
<string>test1.png</string>
</dict>
</dict>
</plist>
请问怎么读取,我想把这些信息保存到一个自定义类中
1 public class Farame
2 {
3 public Frames[] frames;
4 public Metadata metadata;
5 }
6
7 public class Frames
8 {
9 public string name;
10 public Vector2[] frame;
11 public Vector2 offset;
12 public bool rotated;
13 public Vector2[] sourceColorRect;
14 public Vector2 sourceSize;
15 }
16
17 public class Metadata
18 {
19 public int format;
20 public string realTextureFileName;
21 public Vector2 size;
22 public string textureFileName;
23 }
我只会XmlSerializer的方法,想请教下:)
http://www.cnblogs.com/jacklandrin/archive/2013/02/07/2908968.html
XmlSerializer serializer =new XmlSerializer(typeof(PurchaseOrder));
FileStream fs = new FileStream(filename, FileMode.Open);
PurchaseOrder po = new PurchaseOrder();
po = (PurchaseOrder)serializer.Deserialize(fs);
请问下,PurchaseOrder怎么写?
@oulok:
public class plist{
public dict dict{set;get;}
}
public dict{
public string key{set;get;}
public dict {set;get;}
}
@無限遐想:
- -不好意思 ,不太懂这个,能解释下吗.我是想按照提问里那个类去定义他
@oulok: 你用你定義的類,寫一下xml,就知道了哦
你的这种格式是需要自己解析的吧,因为你的有一些标签是类型,而text值却是属性的值。需要你自己解析。像这样的使用xmlnode解析起来应该不难吧!