<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-13107656</id><updated>2009-05-26T14:09:40.673+02:00</updated><title type='text'>Simon Mourier</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://smourier.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13107656/posts/default'/><link rel='alternate' type='text/html' href='http://smourier.blogspot.com/'/><author><name>Simon Mourier</name><uri>http://www.blogger.com/profile/10504799600268175047</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13107656.post-113466289597641820</id><published>2005-12-15T17:02:00.000+01:00</published><updated>2005-12-15T17:08:16.056+01:00</updated><title type='text'>"ActiveX Scripting WebPart" for SharePoint technologies</title><content type='html'>&lt;p&gt;&lt;span style="font-size:85%;"&gt;This is the new home of ActiveX Scripting WebPart that was previously located at &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://blogs.msdn.com/smourier/archive/2003/07/13/181836.aspx"&gt;http://blogs.msdn.com/smourier/archive/2003/07/13/181836.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;Comments and questions are welcome!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;Simon.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;Yes, this sounds heretic, and it probably is :-) This is a generic sample (use it at your own risk :-) WebPart for SharePoint technologies (means it works for Microsoft Windows SharePoint Services as well as Microsoft SharePoint Portal Server 2003) that runs an ActiveX Scripting code on the server.&lt;br /&gt;By default, VBScript and JScript (a.k.a JavaScript) are supported on decent Windows installations, but nothing prevents you from using Python, Perl or other languages that have an ActiveX Scripting existence. Here is an example of such a code (in VBScript) that displays the user name and the current date:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;color:#000000;"&gt;Sub Render(writer)&lt;br /&gt;    writer.Write "User: " &amp; Context.User.Name &amp;amp; "&amp;lt;br&amp;gt;"&lt;br /&gt;    writer.Write "Date: " &amp; Now&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;u&gt;&lt;a href="http://www.codefluent.com/smourier/axwp.htm"&gt;&lt;span style="font-size:85%;"&gt;Binaries and Source code can be downloaded from here&lt;/span&gt;&lt;/a&gt;&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;The WebPart can be installed using SharePoint standard deployment tools:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"&lt;br /&gt; -force -o addwppack -filename ActiveScript.Web.UI.cab&lt;br /&gt; -url &lt;/span&gt;&lt;a href="http://serverNameGoesHere"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;http://serverNameGoesHere&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Or (GAC installation) &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"&lt;br /&gt; -force -o addwppack -filename ActiveScript.Web.UI.cab&lt;br /&gt; -globalinstall -url &lt;/span&gt;&lt;a href="http://serverNameGoesHere"&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;http://serverNameGoesHere&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;The WebPart caches a compiled version of the scripts. If you want to disable this cache, just add the following to your web.config:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&amp;lt;appSettings&amp;gt;&lt;br /&gt; ...&lt;br /&gt; &amp;lt;add key="ScriptCachingMode" value="disabled" /&amp;gt;&lt;br /&gt; ...&lt;br /&gt;&amp;lt;/appSettings&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Using the standard WebPart modification tools provided by the SharePoint WebPart Framework (Design Page, Browse, Modify, ToolPane, ...), you can switch the WebPart from Edit Mode to Run Mode. In Edit mode, you can type the script code directly into the provided TextArea.&lt;br /&gt;This script code can be put in the main procedure (the one that is not inside a declared procedure, sub or function). In this case, it will run probably at Page initialization. For example, the following script code will render the current user's login name *before* the first &amp;lt;html&amp;gt; declaration: &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Context.Response.Write Context.User.Name&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;Or it can be placed inside predefined "Emulated" function. Supported emulated functions prototypes are (the syntax here is in VBScript): &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Sub OnInit()&lt;br /&gt;' Code put here will run in the OnInit method&lt;br /&gt;' of the ActiveX Scripting WebPart&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Sub OnLoad()&lt;br /&gt;' Code put here will run in the OnLoad method&lt;br /&gt;' of the ActiveX Scripting WebPart&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Sub OnPreRender()&lt;br /&gt;' Code put here will run in the OnPreRender method&lt;br /&gt;' of the ActiveX Scripting WebPart&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Sub Render(writer)&lt;br /&gt;' Code put here will run in the Render method&lt;br /&gt;' of the ActiveX Scripting WebPart&lt;br /&gt;' The Writer object has only one Write(object obj) method&lt;br /&gt;' see the example at the beginning&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Sub OnUnload()&lt;br /&gt;' Code put here will run in the OnUnload method&lt;br /&gt;' of the ActiveX Scripting WebPart&lt;br /&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;"Emulated" ASP.Net Object Model:&lt;br /&gt;&lt;/strong&gt;--------------------------------------------------------------------------------&lt;br /&gt;As already demonstrated before, the script code recognizes one "named object" (in ActiveX Scripting terminology) which is "Context" (sounds familiar?). From this context object, the ActiveX Scripting WebPart provides limited support for an "emulated" ASP.Net HttpContext object model. Please consult ASP.Net documentation for details on the following properties and methods. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;Legend:&lt;br /&gt; +:  Class&lt;br /&gt; R:  Read Only property&lt;br /&gt; RW: Read Write property&lt;br /&gt; M:  Method):&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;+ Context&lt;br /&gt;  + Cache&lt;br /&gt;    M  void Insert(string key, object value)&lt;br /&gt;    M  object Get(string key)&lt;br /&gt;    R  int Count&lt;br /&gt;    M  object Remove(string key)&lt;br /&gt;   &lt;br /&gt;  + Request&lt;br /&gt;    R  int ContentLength&lt;br /&gt;    R  string CurrentExecutionFilePath&lt;br /&gt;    R  bool IsAuthenticated&lt;br /&gt;    R  bool IsSecureConnection&lt;br /&gt;    R  string Path&lt;br /&gt;    R  string PathInfo&lt;br /&gt;    R  string PhysicalApplicationPath&lt;br /&gt;    R  string PhysicalPath&lt;br /&gt;    R  string RawUrl&lt;br /&gt;    R  string RequestType&lt;br /&gt;    R  int TotalBytes&lt;br /&gt;    R  string UserHostAddress&lt;br /&gt;    R  string UserHostName&lt;br /&gt;    M  void ValidateInput()&lt;br /&gt;    M  void SaveAs(string filename, bool includeHeaders)&lt;br /&gt;    M  void MapPath(string virtualPath, string baseVirtualDir,&lt;br /&gt;     bool allowCrossAppMapping)&lt;br /&gt;    R  string UserAgent&lt;br /&gt;    R  string HttpMethod&lt;br /&gt;    R  string ContentType&lt;br /&gt;    RW Encoding ContentEncoding&lt;br /&gt;    R  string ApplicationPath&lt;br /&gt;    R  string FilePath   &lt;br /&gt;&lt;br /&gt;  + Response&lt;br /&gt;    RW bool SuppressContent&lt;br /&gt;    R  bool IsClientConnected&lt;br /&gt;    RW bool Buffer&lt;br /&gt;    RW bool BufferOutput&lt;br /&gt;    RW string StatusDescription&lt;br /&gt;    RW string Charset&lt;br /&gt;    RW string Status&lt;br /&gt;    RW string CacheControl&lt;br /&gt;    RW string RedirectLocation&lt;br /&gt;    RW int Expires&lt;br /&gt;    RW DateTime ExpiresAbsolute&lt;br /&gt;    RW string ContentType&lt;br /&gt;    RW Encoding ContentEncoding&lt;br /&gt;    RW int StatusCode&lt;br /&gt;    M  void AddHeader(string name, string value)&lt;br /&gt;    M  void AppendHeader(string name, string value)&lt;br /&gt;    M  void AppendToLog(string param)&lt;br /&gt;    M  void ApplyAppPathModifier(string virtualPath)&lt;br /&gt;    M  void BinaryWrite(byte[] buffer)&lt;br /&gt;    M  void Pics(string value)&lt;br /&gt;    M  void SetCookie(string name, string value)&lt;br /&gt;    M  void TransmitFile(string filename)&lt;br /&gt;    M  void Clear()&lt;br /&gt;    M  void ClearContent()&lt;br /&gt;    M  void ClearHeaders()&lt;br /&gt;    M  void Close()&lt;br /&gt;    M  void End()&lt;br /&gt;    M  void Flush()&lt;br /&gt;    M  void Redirect(string url, bool endResponse)&lt;br /&gt;    M  void Write(object obj)&lt;br /&gt;   &lt;br /&gt;  + Server&lt;br /&gt;    R  string MachineName&lt;br /&gt;    R  int ScriptTimeout&lt;br /&gt;    M  void ClearError()&lt;br /&gt;    M  object CreateObject(string progID)&lt;br /&gt;    M  object CreateObjectFromClsid(string clsid)&lt;br /&gt;    M  string HtmlDecode(string s)&lt;br /&gt;    M  string HtmlEncode(string s)&lt;br /&gt;    M  string MapPath(string path)&lt;br /&gt;    M  void Transfer(string path, bool preserveForm)&lt;br /&gt;    M  string UrlDecode(string s)&lt;br /&gt;    M  string UrlEncode(string s)&lt;br /&gt;    M  string UrlPathEncode(string s)&lt;br /&gt;   &lt;br /&gt;  + Session (no method implemented so far..., coding anyone ?)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;  + Trace&lt;br /&gt;    R  TraceMode TraceMode&lt;br /&gt;    R  bool IsEnabled&lt;br /&gt;    M  void Write(string message)&lt;br /&gt;    M  void Warn(string message)&lt;br /&gt;   &lt;br /&gt;  + User&lt;br /&gt;    R  string Name&lt;br /&gt;    R  string AuthenticationType&lt;br /&gt;    R  bool IsAuthenticated&lt;br /&gt;    M  bool IsInRole(string role)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13107656-113466289597641820?l=smourier.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smourier.blogspot.com/feeds/113466289597641820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=13107656&amp;postID=113466289597641820' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13107656/posts/default/113466289597641820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13107656/posts/default/113466289597641820'/><link rel='alternate' type='text/html' href='http://smourier.blogspot.com/2005/12/activex-scripting-webpart-for.html' title='&quot;ActiveX Scripting WebPart&quot; for SharePoint technologies'/><author><name>Simon Mourier</name><uri>http://www.blogger.com/profile/10504799600268175047</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11245140656005928572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13107656.post-111683883385738769</id><published>2005-05-23T10:54:00.000+02:00</published><updated>2006-08-18T13:02:21.600+02:00</updated><title type='text'>.NET Html Agility Pack: How to use malformed HTML just like it was well-formed XML...</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;strong&gt;!! Update 06/08/18 !!&lt;/strong&gt; The home of Html Agility Pack has changed again (hopefully for the last time...). The project is now located at CodePlex, available here:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=htmlagilitypack"&gt;http://www.codeplex.com/Wiki/View.aspx?ProjectName=htmlagilitypack&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Comments and questions are welcome!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Simon.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Here is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT. It is an assembly that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Sample applications:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Page fixing or generation. You can fix a page the way you want, modify the DOM, add nodes, copy nodes, you name it.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Web scanners. You can easily get to img/src or a/hrefs with a bunch XPATH queries.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;Web scrapers. You can easily scrap any existing web page into an RSS feed for example, with just an XSLT file serving as the binding. An example of this is provided.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;There is no dependency on anything else than .Net's XPATH implementation. There is no dependency on Internet Explorer's dll or tidy or anything like that. There is also no adherence to XHTML or XML, although you can actually produce XML using the tool.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;For example, here is how you would fix all hrefs in an HTML file: &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;HtmlDocument doc = new HtmlDocument();&lt;br /&gt;doc.Load("file.htm");&lt;br /&gt;foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href"])&lt;br /&gt;{&lt;br /&gt;HtmlAttribute att = link["href"];&lt;br /&gt;att.Value = FixLink(att);&lt;br /&gt;}&lt;br /&gt;doc.Save("file.htm"); &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;You can still download the .NET Framework 1.1 version &lt;/span&gt;&lt;a href="http://www.codefluent.com/smourier/download/htmlagilitypack.zip"&gt;&lt;span style="font-size:85%;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;, and for the .NET Framework 2.0 version, please go to CodePlex (link above)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Note: This page was previously located at &lt;a href="http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx"&gt;http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx&lt;/a&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/13107656-111683883385738769?l=smourier.blogspot.com'/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smourier.blogspot.com/feeds/111683883385738769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=13107656&amp;postID=111683883385738769' title='190 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13107656/posts/default/111683883385738769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13107656/posts/default/111683883385738769'/><link rel='alternate' type='text/html' href='http://smourier.blogspot.com/2005/05/net-html-agility-pack-how-to-use.html' title='.NET Html Agility Pack: How to use malformed HTML just like it was well-formed XML...'/><author><name>Simon Mourier</name><uri>http://www.blogger.com/profile/10504799600268175047</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11245140656005928572'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>190</thr:total></entry></feed>