No, they are technically not.
- The default namespace for the second document is an empty string.
- The first document is not aware about the
ns2 prefix.
This can be fixed by making sure both xmlns:ns2="http://www.mycompany.com" and xmlns="http://www.mycompany.com" are present in both documents, despite only one will be used in each.
However, in terms of querying these XMLs, yes, they are identical.
Well, not exactly.
The nodes will be found, but the output format will be different (at least, using .NET xml thingies). For instance, if you query these two documents for "http://www.mycompany.com":firstname, you will get
<firstname xmlns="http://www.mycompany.com">James</firstname>
and
<ns2:firstname xmlns:ns2="http://www.mycompany.com">James</ns2:firstname>
respectively.
But if you make sure both xmlns and xmlns:ns2 are known to both documents, then the output format will be the same:
<firstname xmlns="http://www.mycompany.com">James</firstname> <firstname xmlns="http://www.mycompany.com">James</firstname>