How do I set a namespace prefix to an XAttribute in .NET?

后端 未结 3 1776
清歌不尽
清歌不尽 2021-02-19 02:31

All, I want to create a soap envelope xml document eg.



        
3条回答
  •  無奈伤痛
    2021-02-19 03:05

    You need to use the XName.Get method to construct the attribute name with a namespace:

    var xName = XName.Get("myAttributeName", "http://www.w3.org/2001/XMLSchema-instance");
    var attr = new XAttribute(xName, "myAttributeValue");
    

提交回复
热议问题