<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.NET Tips and Tricks &#187; linq</title>
	<atom:link href="http://kossovsky.net/index.php/tag/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://kossovsky.net</link>
	<description>C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks</description>
	<lastBuildDate>Sat, 25 Dec 2010 08:32:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>C# Parsing HTML with HtmlAgilityPack</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-html-parser-htmlagilitypack/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-html-parser-htmlagilitypack/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 16:00:02 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[c-sharp]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[googling]]></category>
		<category><![CDATA[great library]]></category>
		<category><![CDATA[hn]]></category>
		<category><![CDATA[html document]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[mshtml]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[selectnodes]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[webbrowser control]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=508</guid>
		<description><![CDATA[Let&#8217;s say you have to parse some HTML, find all images or some other DOM elements make some changes/optimizations and save the result. What can you do ? Well, i needed something like that a few days ago and after Googling for couple of hours I ran across this this great library called HtmlAgilityPack. Sure, [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.6" /></div><div>Rating: 4.6/<strong>5</strong> (16 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have to parse some HTML, find all images or some other DOM elements make some changes/optimizations and save the result. What can you do ?</p>
<p>Well, i needed something like that a few days ago and after Googling for couple of hours I ran across this this great library called <a href="http://htmlagilitypack.codeplex.com" target="_blank">HtmlAgilityPack</a>.</p>
<p><span id="more-508"></span></p>
<p>Sure, you can do it by using C# WebBrowser control or MSHTML, but you will have to forget about performance or multithreading &#8211; it will eat all your memory and the CPU won&#8217;t know what&#8217;s hit it.</p>
<p>Now, back to the HtmlAgilityPack.<br />
The usage is very simple, and the performance is great ( at least for my needs ).</p>
<p>Following is an example how we can find all images without an &#8220;alt&#8221; attribute, add it and resave the Html document.</p>
<pre class="c-sharp" name="code">
            HtmlDocument HD = new HtmlDocument();
            HD.Load (@"e:\test.htm");
            var NoAltElements = HD.DocumentNode.SelectNodes("//img[not(@alt)]");
            if (NoAltElements != null)
            {
                foreach (HtmlNode HN in NoAltElements)
                {
                    HN.Attributes.Append("alt", "no alt image");
                }
            }

            HD.Save(@"e:\test.htm");
</pre>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.6" /></div><div>Rating: 4.6/<strong>5</strong> (16 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-html-parser-htmlagilitypack%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-html-parser-htmlagilitypack/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>C# LINQ Teaser</title>
		<link>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/</link>
		<comments>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:31:00 +0000</pubDate>
		<dc:creator>Xander</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teasers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[c-sharp]]></category>
		<category><![CDATA[delegate]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[interview question]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[lt]]></category>
		<category><![CDATA[main string]]></category>
		<category><![CDATA[net c#]]></category>
		<category><![CDATA[Puzzle]]></category>
		<category><![CDATA[puzzles]]></category>
		<category><![CDATA[string args]]></category>
		<category><![CDATA[tezer]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[toarray]]></category>
		<category><![CDATA[visual c#]]></category>

		<guid isPermaLink="false">http://kossovsky.net/?p=517</guid>
		<description><![CDATA[Another great interview question. Will the following code compile and if yes what will be the result of it ? static void Main(string[] args) { int[] array = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Func&#60;int, int&#62; func = i =&#62; { Console.Write(array[i]); return i; }; var result = array.Where(e =&#62; [...]<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.8" /></div><div>Rating: 4.8/<strong>5</strong> (9 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />]]></description>
			<content:encoded><![CDATA[<p>Another great interview question.</p>
<p>Will the following code compile and if yes what will be the result of it ?<br />
<span id="more-517"></span></p>
<pre class="c#" name="code">static void Main(string[] args)
{
    int[] array = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

    Func&lt;int, int&gt; func = i =&gt; {
                          Console.Write(array[i]);
                          return i;
                     };

    var result = array.Where(e =&gt; e &lt;= func(2)).ToArray ();
}</pre>
<br /><div><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx.php?value=4.8" /></div><div>Rating: 4.8/<strong>5</strong> (9 votes cast)</div><br /><a target="_blank" href="http://www.gdstarrating.com/"><img src="http://kossovsky.net/wp-content/plugins/gd-star-rating/gfx/powered.png" border="0" width="80" height="15" /></a><br />
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fkossovsky.net%2Findex.php%2F2009%2F07%2Fcsharp-linq-teaser%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://kossovsky.net/index.php/2009/07/csharp-linq-teaser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

