SharePoint Web Service Example – Grabbing Wiki Content

I presented a session at Tech Ready (Microsoft internal conference) yesterday. One of the samples I showed was how information can be consumed from a SharePoint web service and repurposed. The specific example was taking the Wiki content we host internally on our FAQ site (it’s a great example of using Wikis to build a Frequently Asked Questions knowledgebase) and creating an html file from it.

The code sample is straightforward. I developed it using Visual C# Express Edition on my Vista laptop. The web reference I added was http://faq/sites/sharepoint/_vti_bin/lists.asmx.

In this particular sample, I retrieve content from a specific view. In that view, I’ve actually added the Wiki Content field which is why the content is returned. Instead of getting content from a specific view, I could have specified a query and the fields I wanted returned as parameters to the web service.

Here’s the sample:

SharePoint_FAQ_Lists.Lists ls = new SharePoint_FAQ_Lists.Lists();

ls.Credentials = System.Net.CredentialCache.DefaultCredentials;

string url = “http://faq/sites/sharepoint”;

ls.Url = url + @”/_vti_bin/lists.asmx”;


//get all wiki pages from the “Wiki Pages” library from a particular view. The second parameter is the GUID of the view

XmlNode wListItems = ls.GetListItems(“Wiki Pages”, “{3F1DB907-7D89-4139-99EC-443D1F9BECC7}”, null, null, “”, null, “”);


//assemble the html content that will eventually

string htmlBody = “<html><body>”;


//iterate through the returned XML and parse out the relevant information

foreach (XmlNode outerNode in wListItems.ChildNodes)


if (outerNode.NodeType.Equals(System.Xml.XmlNodeType.Element))


foreach (XmlNode node in outerNode.ChildNodes)


if (node.NodeType.Equals(System.Xml.XmlNodeType.Element))


XmlNode nameNode = node.Attributes.GetNamedItem(“ows_LinkFilename”);

XmlNode wikiNode = node.Attributes.GetNamedItem(“ows_WikiField”);


String wikiName = nameNode.InnerText;

String wikiBody = wikiNode.InnerText;


htmlBody += “<a href=\”” + “http://faq/sites/sharepoint/wiki pages/”+ wikiName + “\”>” + wikiName + “</a><br>”;

htmlBody += wikiBody;






htmlBody += “</body></html>”;


string fileName = @”c:\temp.html”

GenerateFile(htmlBody, fileName);

Comments (7)

  1. very nice to see how you can extract wiki pages and info from the webservices in SP 2007….

    Some time ago, I also posted some code which used the web service of sharepoint (2003):

    …it has been running from the scheduler on my server for years now, generating an RSS feed from a friend’s sharepoint day in day out….

    web services are cool (REST web services are even cooler, tough…)

  2. Después de unas semanas de vacaciones (cortas :PPP), aqui estamos de nuevo en el CIIN al pie del cañón

  3. 2007 MOSS Resource Links (Microsoft Office SharePoint Server) Here is an assortment of various 2007 Microsoft

  4. Using SharePoint web services to get list items

  5. Using SharePoint web services to get list items

  6. Steve Fox says:

    One of the key things you’ll likely want to do with SharePoint is interact a lot with lists. In earlier