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
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CstmrCdtTrfInitn>
    <GrpHdr>
      <MsgId>Copy Cart Urgent28052018_57894</MsgId>
      <CreDtTm>2018-06-29T11:52:23</CreDtTm>
      <NbOfTxs>1</NbOfTxs>
      <CtrlSum>667896.00</CtrlSum>
      <InitgPty>
        <Nm>COPY CART LIMITED</Nm>
        <Id>
          <OrgId>
            <Othr>
              <Id>S001234/PJones</Id>
              <SchmeNm>
                <Cd>CUST</Cd>
              </SchmeNm>
            </Othr>
          </OrgId>
        </Id>
      </InitgPty>
    </GrpHdr>
    <PmtInf>
      <PmtInfId>Payment for addon development SAP B1</PmtInfId>
      <PmtMtd>TRF</PmtMtd>
      <BtchBookg>false</BtchBookg>
      <NbOfTxs>1</NbOfTxs>
      <CtrlSum>667896.00</CtrlSum>
      <PmtTpInf>
        <InstrPrty>HIGH</InstrPrty>
      </PmtTpInf>
      <ReqdExctnDt>2018-06-29</ReqdExctnDt>
      <Dbtr>
        <Nm>COPY CART LIMITED</Nm>
      </Dbtr>
      <DbtrAcct>
        <Id>
          <Othr>
            <Id>0100000110846</Id>
          </Othr>
        </Id>
        <Ccy>KES</Ccy>
      </DbtrAcct>
      <DbtrAgt>
        <FinInstnId>
          <BIC>SBICKENX</BIC>
         </FinInstnId>
      </DbtrAgt>
      <CdtTrfTxInf>
        <PmtId>
          <EndToEndId>156335578965</EndToEndId>
        </PmtId>
        <Amt>
          <InstdAmt Ccy="KES">667896.00</InstdAmt>
        </Amt>
        <ChrgBr>DEBT</ChrgBr>
        <CdtrAgt>
          <FinInstnId>
            <BIC>DTKEKENA</BIC>
            <ClrSysMmbId>
              <MmbId>63000</MmbId>
            </ClrSysMmbId>
          </FinInstnId>
        </CdtrAgt>
        <Cdtr>
          <Nm>EOH SEAL LTD</Nm>
          <PstlAdr>
            <StrtNm>P.O. Box 10496</StrtNm>
            <TwnNm>Nairobi</TwnNm>
            <Ctry>KE</Ctry>
            <AdrLine>P.O. Box 10496</AdrLine>
            <AdrLine>00100 NAIROBI</AdrLine>
          </PstlAdr>
        </Cdtr>
        <CdtrAcct>
          <Id>
            <Othr>
              <Id>0112406001</Id>
            </Othr>
          </Id>
        </CdtrAcct>
        <RmtInf>
          <Ustrd>Copy Cat Urgent28052018_57894</Ustrd>
        </RmtInf>
      </CdtTrfTxInf>
        </PmtInf>
  </CstmrCdtTrfInitn>
</Document>


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.
Posted
Comments
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