C# XML元素格式标记

C# XML元素格式标记,c#,xml,linq-to-xml,xelement,C#,Xml,Linq To Xml,Xelement,我正在使用 new XElement("InstdAmt", "1000") 但是,我想在第一个标记中添加货币,如下所示。请问我怎么做 仅使用第一个标记 new XElement("InstdAmt Ccy=EUR", "1000") 所以我可以得到这个结果 <InstdAmt Ccy="EUR">1000</InstdAmt> 1000 只需添加一个属性: new XElement("InstdAmt", new XAttribute("Ccy", "Eur")

我正在使用

new XElement("InstdAmt", "1000")
但是,我想在第一个标记中添加货币,如下所示。请问我怎么做

仅使用第一个标记

new XElement("InstdAmt Ccy=EUR", "1000")
所以我可以得到这个结果

<InstdAmt Ccy="EUR">1000</InstdAmt>
1000
只需添加一个属性:

 new XElement("InstdAmt", new XAttribute("Ccy", "Eur"), "1000");