I want to write some code that spiders my wiki and consolidates the content into a single document.
I know that I can create a view that has a similar effect, however, there is no effective way to sort the view in a logical order, i.e. if I spider I can go from page to page in the same order the document is laid out.
Any ideas

How to Programmatically Access Wiki Content
Christie Myburgh
I am using WSS.
I have written code that accesses the SPList object for the entries. My problem is that I can't seem to find any method or property to get the actual _content_ of the entry. Title, URL, etc, all available but the content itself, I can't seem to find.
Alok_sriashoka_Patna _city
btw, found the solution to the src of the image..
It has to be a complete url of the image..
Jabber
Well.. I've figured out how to catch the HTML and I can edit the HTML, however it removes the src on images when displayed
I've marked the ways to capture the HTML with red below..
foreach (SPListItem sli in list.Items)
{
if (sli.Name.ToLower() == "home.aspx")
{
string html = sli["Wiki Content"].ToString();
foreach (SPLink spln in sli.ForwardLinks)
{
if (spln.IsInternal)
{
SPFile f = list.ParentWeb.GetFile(spln.ServerRelativeUrl);
html = f.Properties["WikiField"].ToString();
MrFile
Vishal Chopra
For anyone else's reference, here is the code:
public class WikiExport
{
private StringBuilder _buffer; private List<string> _exportedUrls; private SPList _wiki; public WikiExport(SPList list){
_wiki = list;
}
public string Export(){
_buffer =
new StringBuilder();_exportedUrls =
new List<string>(); SPListItem home = null; foreach (SPListItem sli in _wiki.Items){
if (sli.Name.ToLower() == "home.aspx"){
home = sli;
continue;}
}
if (home != null){
_buffer.Append(home[
"Wiki Content"].ToString());_buffer.Append(
"<hr />");Spider(home.ForwardLinks);
return _buffer.ToString();}
else return "";}
private void Spider(SPLinkCollection links){
foreach (SPLink spln in links){
if (spln.IsInternal && !_exportedUrls.Contains(spln.ServerRelativeUrl)){
SPFile f = _wiki.ParentWeb.GetFile(spln.ServerRelativeUrl); try{
if (f.Properties["ContentType"] != null && f.Properties["ContentType"].ToString() == "Wiki Page"){
_buffer.Append(
"<b>");_buffer.Append(f.Title);
_buffer.Append(
"</b><br />");_buffer.Append(f.Properties[
"WikiField"].ToString());_buffer.Append(
"<hr />");_exportedUrls.Add(spln.ServerRelativeUrl);
Spider(f.ForwardLinks);
}
}
catch (FileNotFoundException) { }}
public class WikiExport{
private StringBuilder _buffer; private List<string> _exportedUrls; private SPList _wiki; public WikiExport(SPList list){
_wiki = list;
}
public string Export(){
_buffer =
new StringBuilder();_exportedUrls =
new List<string>(); SPListItem home = null; foreach (SPListItem sli in _wiki.Items){
if (sli.Name.ToLower() == "home.aspx"){
home = sli;
continue;}
}
if (home != null){
_buffer.Append(home[
"Wiki Content"].ToString());_buffer.Append(
"<hr />");Spider(home.ForwardLinks);
return _buffer.ToString();}
else return "";}
private void Spider(SPLinkCollection links){
foreach (SPLink spln in links){
if (spln.IsInternal && !_exportedUrls.Contains(spln.ServerRelativeUrl)){
SPFile f = _wiki.ParentWeb.GetFile(spln.ServerRelativeUrl); try{
if (f.Properties["ContentType"] != null && f.Properties["ContentType"].ToString() == "Wiki Page"){
_buffer.Append(
"<b>");_buffer.Append(f.Title);
_buffer.Append(
"</b><br />");_buffer.Append(f.Properties[
"WikiField"].ToString());_buffer.Append(
"<hr />");_exportedUrls.Add(spln.ServerRelativeUrl);
Spider(f.ForwardLinks);
}
}
catch (FileNotFoundException) { }}
}
}
public class WikiExport{
private StringBuilder _buffer; private List<string> _exportedUrls; private SPList _wiki; public WikiExport(SPList list){
_wiki = list;
}
public string Export(){
_buffer =
new StringBuilder();_exportedUrls =
new List<string>(); SPListItem home = null; foreach (SPListItem sli in _wiki.Items){
if (sli.Name.ToLower() == "home.aspx"){
home = sli;
continue;}
}
if (home != null){
_buffer.Append(home[
"Wiki Content"].ToString());_buffer.Append(
"<hr />");Spider(home.ForwardLinks);
return _buffer.ToString();}
else return "";}
private void Spider(SPLinkCollection links){
foreach (SPLink spln in links){
if (spln.IsInternal && !_exportedUrls.Contains(spln.ServerRelativeUrl)){
SPFile f = _wiki.ParentWeb.GetFile(spln.ServerRelativeUrl); try{
if (f.Properties["ContentType"] != null && f.Properties["ContentType"].ToString() == "Wiki Page"){
_buffer.Append(
"<b>");_buffer.Append(f.Title);
_buffer.Append(
"</b><br />");_buffer.Append(f.Properties[
"WikiField"].ToString());_buffer.Append(
"<hr />");_exportedUrls.Add(spln.ServerRelativeUrl);
Spider(f.ForwardLinks);
}
}
catch (FileNotFoundException) { }}
}
}
}
}
NozFx
foreach (SPListItem sli in list.Items) { if (sli.Name.ToLower() == "home.aspx") { foreach (SPLink spln in sli.ForwardLinks) { if (spln.IsInternal) { SPFile f = list.ParentWeb.GetFile(spln.ServerRelativeUrl); ret += f.Item.Fields["WikiContent"];maulikk
Are you using WSS or MOSS
If you are using MOSS use the Content Query Web Part.
If you are using WSS, you may have to resort to some code to extract the items from the DB and present them in order... you shouldn't have to "Spider Them" but rather access a collection of the objects from the API and sort them the way you want.
Hope that helps,