<?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>Everyday Internet Stuff &#187; Linq</title>
	<atom:link href="http://www.everydayinternetstuff.com/tag/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.everydayinternetstuff.com</link>
	<description>Useful Tips And Tricks For Webmasters</description>
	<lastBuildDate>Tue, 27 Dec 2011 21:01:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Default namespace for LINQ to XML query</title>
		<link>http://www.everydayinternetstuff.com/2009/12/default-namespace-for-linq-to-xml-query/</link>
		<comments>http://www.everydayinternetstuff.com/2009/12/default-namespace-for-linq-to-xml-query/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 00:27:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[XDocument]]></category>
		<category><![CDATA[XElement]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.everydayinternetstuff.com/?p=29</guid>
		<description><![CDATA[Linq rocks completely, however when you write queries against XML documents that have namespaces (and most likely the document will only have one namespace) you have to specify them in your queries. Here&#8217;s a nice solution from mike a moogly.me.uk &#8211; just strip all of the useless namespaces from XDocument object and query away! public [...]]]></description>
			<content:encoded><![CDATA[<p>Linq rocks completely, however when you write queries against XML documents that have namespaces (and most likely the document will only have one namespace) you have to specify them in your queries. Here&#8217;s a nice solution from <a href="http://moggoly.me.uk/blog/post/Removing-default-namespaces-from-an-XDocument.aspx">mike a moogly.me.uk</a> &#8211; just strip all of the useless namespaces from XDocument object and query away!</p>
<blockquote><p>public void RemoveNamespace(XDocument xdoc)</p>
<p>{</p>
<p>foreach (XElement e in xdoc.Root.DescendantsAndSelf())</p>
<p>{</p>
<p>if (e.Name.Namespace != XNamespace.None)</p>
<p>{</p>
<p>e.Name = XNamespace.None.GetName(e.Name.LocalName);</p>
<p>}</p>
<p>if (e.Attributes().Where(a =&gt; a.IsNamespaceDeclaration || a.Name.Namespace != XNamespace.None).Any())</p>
<p>{</p>
<p>e.ReplaceAttributes(e.Attributes().Select(a =&gt; a.IsNamespaceDeclaration ? null : a.Name.Namespace != XNamespace.None ? new XAttribute(XNamespace.None.GetName(a.Name.LocalName), a.Value) : a));</p>
<p>}</p>
<p>}</p>
<p>}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.everydayinternetstuff.com/2009/12/default-namespace-for-linq-to-xml-query/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

