我从网上得到了一个XML文件,用于我的学校项目中,这个xml文件是kongregate用于在我的网站中嵌入游戏的文件。 xml文件采用ELEMENT格式,但gridview和listview需要采用ATTRIBUTE格式。 这是xml文件的链接:http://www.kongregate.com/games_for_your_site.xml如何使用XML类在gridview或listview中显示XML内容?
我得到了一个关于将它变成类的建议,所以我做了,但我仍然不知道如何使用它。 这是类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for Class1
/// </summary>
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class gameset
{
private gamesetGame[] gameField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("game")]
public gamesetGame[] game
{
get
{
return this.gameField;
}
set
{
this.gameField = value;
}
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class gamesetGame
{
private uint idField;
private string titleField;
private string thumbnailField;
private System.DateTime launch_dateField;
private string categoryField;
private string featured_imageField;
private string[] screenshotField;
private string flash_fileField;
private ushort widthField;
private ushort heightField;
private string urlField;
private string descriptionField;
private string instructionsField;
private string developer_nameField;
private uint gameplaysField;
private decimal ratingField;
private ushort id1Field;
/// <remarks/>
public uint id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
/// <remarks/>
public string title
{
get
{
return this.titleField;
}
set
{
this.titleField = value;
}
}
/// <remarks/>
public string thumbnail
{
get
{
return this.thumbnailField;
}
set
{
this.thumbnailField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType = "date")]
public System.DateTime launch_date
{
get
{
return this.launch_dateField;
}
set
{
this.launch_dateField = value;
}
}
/// <remarks/>
public string category
{
get
{
return this.categoryField;
}
set
{
this.categoryField = value;
}
}
/// <remarks/>
public string featured_image
{
get
{
return this.featured_imageField;
}
set
{
this.featured_imageField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("screenshot")]
public string[] screenshot
{
get
{
return this.screenshotField;
}
set
{
this.screenshotField = value;
}
}
/// <remarks/>
public string flash_file
{
get
{
return this.flash_fileField;
}
set
{
this.flash_fileField = value;
}
}
/// <remarks/>
public ushort width
{
get
{
return this.widthField;
}
set
{
this.widthField = value;
}
}
/// <remarks/>
public ushort height
{
get
{
return this.heightField;
}
set
{
this.heightField = value;
}
}
/// <remarks/>
public string url
{
get
{
return this.urlField;
}
set
{
this.urlField = value;
}
}
/// <remarks/>
public string description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
public string instructions
{
get
{
return this.instructionsField;
}
set
{
this.instructionsField = value;
}
}
/// <remarks/>
public string developer_name
{
get
{
return this.developer_nameField;
}
set
{
this.developer_nameField = value;
}
}
/// <remarks/>
public uint gameplays
{
get
{
return this.gameplaysField;
}
set
{
this.gameplaysField = value;
}
}
/// <remarks/>
public decimal rating
{
get
{
return this.ratingField;
}
set
{
this.ratingField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("id")]
public ushort id1
{
get
{
return this.id1Field;
}
set
{
this.id1Field = value;
}
}
}
你能告诉我如何显示ListView中的数据?或者你可以将我的xml文件从元素转换为属性?