May, 2008

  • Wriju's BLOG

    LINQ to XML : Querying XML with Namespaces


    This question arises in one of discussions. If you have a XML document with “xmlns” then LINQ to XML does not return any IEnumerable<T> J. This is strange but true for XPath and XQuery.

    There is a trick to get it done,

    Let us assume that you have a XML as follows,

    <?xml version="1.0" encoding="utf-8"?>

    <products xmlns="myns-com">

      <product ProductID="1" CategoryID="1">



      <product ProductID="2" CategoryID="1">




    Now this code holds namespace and all the child element’s default namespace would be that one “myns-com”.

    So if you try to write query against this XML

    var query = from lst in XElement.Load(@"c:\NS.xml").Elements(“product")

                select (int)lst.Attribute("ProductID");


    foreach (var k in query)




    This seems correct though it will not give you any output.

    What you need to do is, you need to the namespace in the query,

    XNamespace ns = "myns-com";


    var query = from lst in XElement.Load(@"c:\NS.xml").Elements(ns+"product")

                select (int)lst.Attribute("ProductID");


    foreach (var k in query)




    You will get the desired output as you may expect.


  • Wriju's BLOG

    Internet Explorer 8 : Will the existing sites break?


    With IE 8 and strong CSS 2.1 compliance, the sites which used to run perfectly fine with IE 7 might break. The error typically could be like, formatting, alignment or JavaScript issues. This is beta and there are ways to prevent all such problems easily.

    We do not have to follow the CSS 2.1 standard to be able to run it in IE 8. If your site runs on IE 7 without any issue the same will run on IE 8 with some simple effort. This has been described well in the KB Article # 952030.

    Option 1:

    In IIS you can add the following header info,

    X-UA-Compatible: IE=EmulateIE7

    Option 2:

    In the web.config under configuration section you can add  add,




          <clear />

          <add name="X-UA-Compatible" value="IE=EmulateIE7" />





    Option 3:

    You can modify a single page by adding meta tag,

    <html xmlns="" >

    <head runat="server">

        <title>Untitled Page</title>

        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />



        <form id="form1" runat="server">







    Find more on Microsoft's Interoperability Principles and IE8.


  • Wriju's BLOG

    Internet Explorer 8: Start of a new era


    Being web developer I am super excited about the release of Internet Explorer 8. There are lots of talks and already we have Beta 1. Now there are some thousands features with this version and many are planned for the new version. Excitements anxiousness and many more..

    The two major goals for this release are

    Ø  Developer productivity

    Ø  User productivity

    This version of IE allows us (anyone regardless he is pro/dev) to be able to customize. There were bugs in IE7 that are addressed here apart from the new features.

    The WebSlice and Activity are the most amazing things here. If you install it you will enjoy them.

    Some start up resources,

    Find more on,


  • Wriju's BLOG

    Visual Studio 2008 Product Comparison


    One of the mostly asked questions in the Visual Studio adopters group is “what am I not getting with my version?”. This probably sometimes leads to a business decision towards buying.

    cover image: Visual Studio 2008 Product Comparison
    Download the data sheet (from MSDN)

    One place for all your queries, at


  • Wriju's BLOG

    LINQ : IEnumerable<T> and IQueryable<T>


    IEnumerable<T> and IQueryable<T> are the two most used terms of any LINQ discussion. What I am trying to here is that I am trying to simplify the two interfaces depending on their behavior. In LINQ world we generally have few providers available within .NET Framework, like LINQ to Object, LINQ to SQL, LINQ to XML.


    It is a statement that every LINQ statement returns IEnumerable<T>. IEnumerable works in steps. Meaning, when you write,


    var q = from a in b

               where a > 5

               select a;

    It creates a list out “b” depending on “where” then it creates another list for “select”. This is the behavior of LINQ to Object and LINQ to XML.




    When you use LINQ to SQL it uses IQueryable<T>. This interface inherits from IEnumerable<T> but typically any LINQ to SQL generates T-SQL at the backend to be able to get the data for us. This evaluate and generates the query at one shot and gives us the whole data.





Page 1 of 1 (5 items)