Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this template from a bank that is used to make payments on bank account transfers.

See xml below. I have included the sample data that has to be entered when sending the file to the bank.

<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="">
      <MsgId>Copy Cart Urgent28052018_57894</MsgId>
        <Nm>COPY CART LIMITED</Nm>
      <PmtInfId>Payment for addon development SAP B1</PmtInfId>
        <Nm>COPY CART LIMITED</Nm>
          <InstdAmt Ccy="KES">667896.00</InstdAmt>
          <Nm>EOH SEAL LTD</Nm>
            <StrtNm>P.O. Box 10496</StrtNm>
            <AdrLine>P.O. Box 10496</AdrLine>
            <AdrLine>00100 NAIROBI</AdrLine>
          <Ustrd>Copy Cat Urgent28052018_57894</Ustrd>

The file is quite long as has to be in the format given. The black letters represent the details to be passed to the xml. To test if I understood what data goes where I filled it manually and sent to bank for testing. That is all good now.

I have a SAP Business One addon program that captures details from a form and generates a list. Each payment must follow this structure.

The data captured in the .xml (black letters) comes a form with rows and columns. So if you have 2 rows of data, the xml will double in size replicating the same fields as above.

What is the best method to create an xml file as above from form data in c#?

What I have tried:

I thought the best way to get c# data would be to gather form data in a List<bankintegration>. Where BankIntegration is a class with properties get/set.

I then used Visual Studio: Edit -> Paste Special -> Paste XML as Classes. What that did was to create numerous classes that seem not useful to me.
F-ES Sitecore 10-Aug-18 8:44am    
Easiest way might be to build the data structure out of classes then use xml serialisation to convert that to XML. There are various ways of doing this, google "c# xml serialisation" for examples.
Gerry Schmitz 10-Aug-18 15:32pm    
"Paste Special" works fine. The "Class Names" reflect the structure of the XML; that's why they look "strange".

The classes WILL work for your trivial case. You just need to spend 5 minutes getting familiar with it; fields, properties and constructors; all "standard".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900