Adding attribute to XML Node always fail



I always get exception below when try to add attribute, why it's not working?



The prefix '' cannot be redefined from '' to 'http://ws.plimus.com' within the same start element tag.



Code



var docXml = new XElement("param-encryption",
new XAttribute("xmlns", "http://ws.plimus.com"),
new XElement("parameters"));

var s = docXml.ToString();


I want to get result like



<param-encryption xmlns="http://ws.plimus.com">
<parameters>


</parameters>
</param-encryption>

No comments:

Post a Comment