Wednesday, August 4, 2010

Extracting tags from xhtml content

There are two ways of doing it. One is the dirty way, using Mid function in VB.Net or IndexOf string method but the more appropriate way would be to use regular expressions.

Following code will get you title using regular expression
Regex regex = new Regex("<title>(?<title>.*?)</title>", RegexOptions.IgnoreCase);
Match titleMatch = regex.Match(html);
string title = titleMatch.Groups["title"].Value;
Following code will get you meta tag My_Meta

Regex regex = new Regex("<META +NAME=\"(?<name>My_Meta*?)\" +CONTENT=\"(?<content>.*?)\" */?>", RegexOptions.IgnoreCase);
Match metaMatch = regex.Match(html);

title = metaMatch.Groups["content"].Value;

Thursday, July 15, 2010

Saving objects using Entity framework

TableClass tableObject = new TableClass();
tableObject.property1 = "Hello";
tableObject.proeprty2 = "World";

// NOTE: make sure to use the same instance of entityContextObject which was used to populate the tableObject (e.g. updating back to database)
entityContextObject.AddToTableClass(tableObject);
entityContextObject.SaveChanges();

Minimize Outlook 2007/2010 to tray

Very easy fix but it should be a default I think. Anyways in 2 easy steps:

1. Click on outlook icon in Notification area (Beside the clock in task bar)
2. Choose Hide when minimized

How to minimize MSN Messenger to the system tray in Windows 7

Not sure why Microsoft has changed the behavior in Windows 7 but its annoying that it takes up two programs in task bar when its running. Follow the link below to see the solution.

Link: http://windows7center.com/tutorials/how-to-minimize-msn-messenger-to-the-system-tray-in-windows-7/

Monday, June 28, 2010

Wednesday, April 14, 2010

Wednesday, March 31, 2010

outputting all attributes except one in xsl

In order to avoid outputting one attribute among all the attributes of a tag, following xpath can be used