I know this is an old topic, but I had the same problem using the XmlDocument class, because I wanted to know the default namespace and the prefix namespace.
I could get both namespaces using the same method.
string prefixns = element.GetNamespaceOfPrefix("prefix");
string defaultns = element.GetNamespaceOfPrefix("");
this seems to work for me, getting both namespaces in an XmlElement.
Edit: this is an XmlNode method, so it should also work with attributes
source
share