<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>You had me at "Hello World" : xml</title><link>http://blogs.msdn.com/helloworld/archive/tags/xml/default.aspx</link><description>Tags: xml</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>I Am in Love with LINQ</title><link>http://blogs.msdn.com/helloworld/archive/2008/03/16/why-you-will-fall-in-love-with-linq.aspx</link><pubDate>Sun, 16 Mar 2008 20:47:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8269756</guid><dc:creator>HelloWorld</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/helloworld/comments/8269756.aspx</comments><wfw:commentRss>http://blogs.msdn.com/helloworld/commentrss.aspx?PostID=8269756</wfw:commentRss><description>&lt;p&gt;I have been reviewing LINQ since last year, but I had never had a chance to actually jump and use it extensively. My last project uses Visual Studio 2008, and there are opportunities to use LINQ.&lt;/p&gt;  &lt;p&gt;Probably because I have reviewed it before, the learning curve was not that steep. I use LINQ to SQL and LINQ to XML, and I love it. Prior to use LINQ, I had to open my XPath reference book when I was dealing with XML and XSLT. Now, I don't really have to deal with the plumbing, and let LINQ does it for me. It increases my productivity. Troubleshooting is much more straightforward.&lt;/p&gt;  &lt;p&gt;LINQ to XML does not replace the flexibility of XPATH and XSLT. I still like the level of control and flexibility that XSLT and XPATH provides, but for most of the time, LINQ to XML serves my need.&lt;/p&gt;  &lt;p&gt;So, if you are using Visual Studio 2008, I encourage you to check it out.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8269756" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/helloworld/archive/tags/xml/default.aspx">xml</category><category domain="http://blogs.msdn.com/helloworld/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>Dynamically Getting Namespaces in an XML</title><link>http://blogs.msdn.com/helloworld/archive/2007/12/28/dynamically-getting-namespaces-in-an-xml.aspx</link><pubDate>Sat, 29 Dec 2007 00:45:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6888902</guid><dc:creator>HelloWorld</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/helloworld/comments/6888902.aspx</comments><wfw:commentRss>http://blogs.msdn.com/helloworld/commentrss.aspx?PostID=6888902</wfw:commentRss><description>&lt;p&gt;I have a utility that process XML files, ideally, I would like to be able to feed XQueries into the application, the problem was, the xml files have namespaces. So far, all examples on how to use XQuery with XmlNamespaceManager requires hard coded namespace, that means I need to know the URI and the prefix. Well, I would like to be able to dynamically get the namespaces.&lt;/p&gt;  &lt;p&gt;I came up with this solution, this method will return an instance of XmlNamespaceManager with a specified XmlNameTable. Unfortunately, XPath 1.0 does not support default namespace, the default namespace will have '&lt;font color="#0000ff"&gt;default&lt;/font&gt;' prefix.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Xml;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Xml.XPath;

&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/span&gt;&lt;span style="color: green"&gt;Returns an instance of XmlNamespaceManager with a specified XmlDocument.NameTable.  
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;Returns null if no namespace is defined.
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name=&amp;quot;Doc&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The XmlDocument&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;XmlNamespaceManager if there is at least one namespace, null if there is no namespace defined.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlNamespaceManager &lt;/span&gt;CreateNamespaceManager(&lt;span style="color: #2b91af"&gt;XmlDocument &lt;/span&gt;Doc)
{
    &lt;span style="color: green"&gt;//Create an instance of XPathNavigator at the root of the XmlDocument.
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XPathNavigator &lt;/span&gt;Nav = Doc.SelectSingleNode(&lt;span style="color: #a31515"&gt;&amp;quot;/*&amp;quot;&lt;/span&gt;).CreateNavigator();
    &lt;span style="color: #2b91af"&gt;XmlNamespaceManager &lt;/span&gt;Result = &lt;span style="color: blue"&gt;null&lt;/span&gt;;

    &lt;span style="color: green"&gt;//Move to the first namespace.
    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(Nav.MoveToFirstNamespace())
    {
        Result = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlNamespaceManager&lt;/span&gt;(Doc.NameTable);

        &lt;span style="color: blue"&gt;do
        &lt;/span&gt;{
            &lt;span style="color: green"&gt;//Add namespaces to XmlNamespaceManager, if the Nav.Name is an empty string, it is the default
            //namespace.  Assign 'default' as the prefix.
            &lt;/span&gt;Result.AddNamespace(&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(Nav.Name)? &lt;span style="color: #a31515"&gt;&amp;quot;default&amp;quot; &lt;/span&gt;: Nav.Name, Nav.Value);
        } &lt;span style="color: blue"&gt;while &lt;/span&gt;(Nav.MoveToNextNamespace());
    }

    &lt;span style="color: blue"&gt;return &lt;/span&gt;Result;
}&lt;/pre&gt;

&lt;p&gt;The XmlNamespaceManager now is generated dynamically, without having to know all namespaces in advance. This gave me the ability to change the XQueries, feed it at runtime to my application without having to recompile the app. I wish XPath 1.0 supports default namespace, it if is, it will be even simpler.&lt;/p&gt;

&lt;p&gt;Hope this helps someone. :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6888902" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/helloworld/archive/tags/xml/default.aspx">xml</category><category domain="http://blogs.msdn.com/helloworld/archive/tags/Programming/default.aspx">Programming</category></item><item><title>Unwanted Meta tag after xlst processing.</title><link>http://blogs.msdn.com/helloworld/archive/2007/03/19/unwanted-meta-tag-after-xlst-processing.aspx</link><pubDate>Mon, 19 Mar 2007 21:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1914159</guid><dc:creator>HelloWorld</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/helloworld/comments/1914159.aspx</comments><wfw:commentRss>http://blogs.msdn.com/helloworld/commentrss.aspx?PostID=1914159</wfw:commentRss><description>&lt;P&gt;I have an xslt that I use to generate a nice HTML representation of Visual Studio unit test result file (.trx), Last week, I discovered a problem, that the generated HTML includes an unwanted&amp;nbsp;META tag. I did not have meta tag in the xslt, and it is bad because the meta tag does not have a closing tag, the generated html is a malformed xml. This makes post-processing little bit dificult.&lt;/P&gt;
&lt;P&gt;It looks like this, notice how the META tag was not closed:&lt;/P&gt;&lt;CODE&gt;&amp;nbsp; &amp;lt;HEAD&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;lt;META http-equiv="Content-Type" content="text/html; charset=utf-8"&amp;gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TITLE&amp;gt;&amp;lt;/TITLE&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/HEAD&amp;gt; &lt;/CODE&gt;
&lt;P&gt;After searching, I discovered the &amp;lt;xsl:output&amp;gt; element. Adding this element to the xslt, makes the html xml-compliant.&lt;/P&gt;&lt;CODE&gt;&amp;lt;xsl:output version="1.0" method="xml" encoding="UTF-8" omit-xml-declaration="yes"&amp;gt;&lt;/CODE&gt; 
&lt;P&gt;After adding the xsl:output element to the xslt, the meta tag is gone.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1914159" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/helloworld/archive/tags/xml/default.aspx">xml</category><category domain="http://blogs.msdn.com/helloworld/archive/tags/Programming/default.aspx">Programming</category></item></channel></rss>