Empty namespace using Linq Xml

后端 未结 3 633
悲&欢浪女
悲&欢浪女 2020-12-14 15:11

I\'m trying to create a sitemap using Linq to Xml, but am getting an empty namespace attribute, which I would like to get rid of. e.g.

XNamespace ns = \"http         


        
3条回答
  •  别那么骄傲
    2020-12-14 16:01

    If one element uses a namespace, they all must use one. In case you don't define one on your own the framework will add a empty namespace as you have noticed. And, sadly, there is no switch or something similiar to suppress this "feature".

    So, there seems to be no better method as to strip it out. Using Replace(" xmlns=\"\"", "") could be a little bit faster than executing a RegEx.

提交回复
热议问题