我需要像这样创建XML请求:
<PosXML version="7.2.0">
<ReadCardRequest>
<Amount>10</Amount>
<CurrencyName>EUR</CurrencyName>
</ReadCardRequest>
</PosXML>
我有PosXML线的问题。它只适用于简单使用PosXML,但在PosXML版本=&#34; 7.2.0&#34;
时会出错我的代码现在:
XDocument doc = new XDocument(new XElement("PosXML",
new XElement("ReadCardRequest",
new XElement("Amount", summa.ToString()),
new XElement("CurrencyName", "EUR"))));
有什么建议吗?
答案 0 :(得分:2)
您可以使用XAttribute:
XDocument doc = new XDocument(new XElement("PosXML",
new XElement("ReadCardRequest",
new XElement("Amount", "1"),
new XElement("CurrencyName", "EUR")),
new XAttribute("version","7.2.0")));
(正如捅也指出)