I need to create XML request like this:
<PosXML version="7.2.0">
<ReadCardRequest>
<Amount>10</Amount>
<CurrencyName>EUR</CurrencyName>
</ReadCardRequest>
</PosXML>
I have problem with PosXML line. It works only when to use simply PosXML but gets error when it is PosXML version="7.2.0"
My code right now:
XDocument doc = new XDocument(new XElement("PosXML",
new XElement("ReadCardRequest",
new XElement("Amount", summa.ToString()),
new XElement("CurrencyName", "EUR"))));
Any suggestions?
You can use an XAttribute for that:
XDocument doc = new XDocument(new XElement("PosXML",
new XElement("ReadCardRequest",
new XElement("Amount", "1"),
new XElement("CurrencyName", "EUR")),
new XAttribute("version","7.2.0")));
(As poke also pointed out)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.