Here is an entire custom webpart I wrote earlier today. It reads an xml that store information about our download section, the xml looks something like this.
<?xml version="1.0" encoding="utf-8"?>
<body>
<file>
<date>2010-12-01</date>
<publish>True</publish>
<publish_up>2010-12-01</publish_up>
<publish_down/>
<user>Eric</user>
<name>Camelot Joomla Tools</name>
<version>1.0 RC1</version>
<folder>files\camelot_joomla_tools\</folder>
<filename>(Unpack_me_first!)_Camelot_Joomla_Tools_1.0_RC1.zip</filename>
<info><![CDATA[
<p>Bendsoft Camelot Joomla Tools is a versatile Joomla component which gives
you the possibility to use and display SharePoint list content in Joomla!. The
SharePoint content can be displayed with different templates as lists or articles.</p>
<p>Bendsoft currently offer two free open source SharePoint web parts to transfer
data from SharePoint to Joomla.</p>]]></info>
<downloads>230</downloads>
<hash>80a369e58f5cee98d3238d507ad31bfa</hash>
</file>
<file>
<date>2011-04-02</date>
<publish>True</publish>
<publish_up>2011-04-12</publish_up>
<publish_down/>
<user>Eric</user>
<name>Camelot.SharepointIntegration.dll</name>
<version>1.0.1</version>
<folder>files\library\</folder>
<filename>Camelot.SharepointIntegration.dll_1.0.1.zip</filename>
<info><![CDATA[
<p>The Camelot Sharepoint Integration is a library containing necessary tools when creating Camelot XML based exports or imports.</p>]]></info>
<downloads>3</downloads>
<hash>ccbd580be5149e8ac78364c1c3133982</hash>
</file>
</body>
And the webpart code
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
namespace BendsoftDownloadStats
{
public class BendsoftDownloadStats : System.Web.UI.WebControls.WebParts.WebPart
{
private string RSSFile = @"C:\windows\temp\downloads.xml";
protected override void CreateChildControls()
{
base.CreateChildControls();
HtmlGenericControl mainDiv = new HtmlGenericControl("div");
mainDiv.ID = "mainDiv";
Controls.Add(mainDiv);
var xmlSource = XElement.Load(RSSFile);
IEnumerable<XElement> q =
(from c in xmlSource.Elements("file")
where (string)c.Element("publish") == "True"
orderby c.Element("name").Value, c.Element("version").Value
select c).ToArray();
foreach (XElement c in q)
{
string insert = string.Empty;
insert += string.Concat(c.Element("name").Value, " (", c.Element("version").Value, ")");
insert += string.Concat(" - <em>", c.Element("date").Value, "</em><br />");
insert += string.Concat("<strong>", c.Element("downloads").Value, "</strong>");
HtmlGenericControl paragraph = new HtmlGenericControl("p");
paragraph.ID = c.Element("hash").Value;
paragraph.InnerHtml = insert;
mainDiv.Controls.Add(paragraph);
}
}
}
}
Simple, very fast and adaptable!