How to prevent blank xmlns attributes in output from .NET's XmlDocument?

前端 未结 7 1317
生来不讨喜
生来不讨喜 2020-11-27 03:56

When generating XML from XmlDocument in .NET, a blank xmlns attribute appears the first time an element without an associated namespace is inserted; ho

7条回答
  •  醉酒成梦
    2020-11-27 04:40

    Yes you can prevent the XMLNS from the XmlElement . First Creating time it is coming : like that

    
        249.118774
        
    
    

    Change the code : And pass xml namespace like this

    C# code:

    XmlElement bookElement = xdoc.CreateElement("trkpt", "http://www.topografix.com/GPX/1/1");
    bookElement.SetAttribute("lat", "30.53597");
    bookElement.SetAttribute("lon", "97.753324");
    

提交回复
热议问题