Namespace declarations in XElement may be inconsistent #109573
Unanswered
nathan130200
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Basically if we implicitly declare the default namespace of the XElement, we cannot access it through the
GetDefaultNamespace()
function, which returnsXNamespace.None
, which is incorrect, since the namespace has already been defined in the current scope and there is no way to change the namespace without having to recursively clone the entire XML tree...Consider the code below:
SharpLab
As you can see, when creating the XElement, it does not consider the problem with the XElement as a valid value for
GetDefaultNamespace
, which is that it considers ONLY what is linked to the XName and it does not make sense.Since what defines the namespace is the URI that qualifies it, if it has a prefix, this prefix determines the scope of the URI. So what should say which namespace the XElement has is the
xmlns
orxmlns:prefix
attribute and not theXName.Namespace
property.I've even opened an issue with this problem before, but since almost a month have passed without any response from anyone, I ended up choosing to close it. But I had to do some projects that use and need XML without having to rewrite the entire DOM mechanism, I encountered this same problem with Namespaces again.
Beta Was this translation helpful? Give feedback.
All reactions