1, Create a XML document named "Medias.xml"
<?xml version="1.0" encoding="utf-8" ?>
<medias>
<media>
<ID>1</ID>
<Name>Gallery 1</Name>
<Folder>~/media/mypath2us</Folder>
<Owner>1</Owner>
</media>
</medias>
2, Create a class to represent the Media object...
public class Media
{
public Media()
{
//
// TODO: Add constructor logic here
//
}
public Media(int nID, string strName, string strFolderUrl, int nOwnerID)
{
//
// TODO: Add constructor logic here
//
this.ID = nID;
this.Name = strName;
this.FolderUrl = strFolderUrl;
this.OwnerID = nOwnerID;
}
public int ID { get; set; }
public string Name { get; set; }
public string FolderUrl { get; set; }
public int OwnerID { get; set; }
}
3, Load the document using System.Xml.Linq ...
XElement rootElement = XElement.Load(Server.MapPath("~/Medias.xml"));
var q = from media in rootElement.Descendants("media")
select new Media((int)media.Element("ID"), (string)media.Element("Name"), (string)media.Element("Folder"), (int)media.Element("Owner"));
this.rptGalleries.DataSource = q; //Bind the result to a repeater control.
this.rptGalleries.DataBind();