I'd like to edit my Sharepoint Wiki content programmatically. One of the advantages would be to add indexes to the Wiki environment automatically.
Has anyone been able to do this? Language doesn't matter, but looking for scripting solution.
sharepointsharepoint-wiki
I'd like to edit my Sharepoint Wiki content programmatically. One of the advantages would be to add indexes to the Wiki environment automatically.
Has anyone been able to do this? Language doesn't matter, but looking for scripting solution.
Best Answer
Yes. I have rolled my own Metaweblog API that programmatically manages wiki pages in Sharepoint 2010 and 2007.
My sources:
The service code for both SP 2010 and 2007 is pretty much identical, but there are a few caveats:
I use the Copy service as in the first link to create AND update the wiki pages. In 2010, you can use the Lists service to update, but not to add. I use the Imaging service to upload images automatically to a picture library.
Here is a function to replace the "ms-wikilinks" to wiki markup:
Note: I use the HTMLAgilityPack in case the markup returned is malformed. You could use Regex to do this too. I also use Microsoft Anti-XSS 4.1 library to sanitize markup.
Note 2: My UrlDecode function does not take a dependency on System.Web, taken from here.
The function to strip SharePoint's HTML is:
And finally, the function that adds that markup all back:
This works great.
I am thinking of publishing my API, it's not a lot of code I think is super helpful for those of us that want to better manage our Sharepoint wikis. With WLW I get auto-image upload, better HTML editing support, and support for plugins like PreCode Snippet. It's awesome!