I found out what the difference is, but not why it is different.
In the first form, you have the xmlns attribute. In the second form, you do not do this - not in terms of returning Attributes() . If you explicitly build an XAttribute , DeepEquals will return true :
var xmlDirect = new XDocument(new XElement( XNamespace.Get("someNamespace") + "someXml", new XAttribute("xmlns", "someNamespace")));
As if the namespace is only considered an attribute when converting a tree to a text representation.
Jon skeet
source share