Hi to all.
I need your help for 2 problems.

Using this code
Code:
        Dim xmlDecl As New XDeclaration("1.0", "UTF-8", "yes")
        Dim path As String = "G:\XML\VB\LoadExcelAndSaveXML2\Test41.xml"
        Dim header As XElement
        Dim detail As XElement
        Dim doc As XDocument
        header = <Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
                     <CstmrCdtTrfInitn>
                         <GrpHdr>
                             <MsgId><%= DataGridView1(0, 0).Value() %></MsgId>
                             <CreDtTm><%= DataGridView1(1, 0).Value() %></CreDtTm>
                             <NbOfTxs><%= DataGridView1(2, 0).Value() %></NbOfTxs>
                             <CtrlSum><%= DataGridView1(3, 0).Value() %></CtrlSum>
                             <InitgPty>
                                 <Id>
                                     <OrgId>
                                         <Othr>
                                             <Id><%= DataGridView1(4, 0).Value() %></Id>
                                             <Issr><%= DataGridView1(5, 0).Value() %></Issr>
                                         </Othr>
                                     </OrgId>
                                 </Id>
                             </InitgPty>
                         </GrpHdr>
                     </CstmrCdtTrfInitn>
                 </Document>
        For Each row As DataGridViewRow In DataGridView1.Rows
            If row.IsNewRow Then Continue For
            detail = <PmtInf>
                         <PmtInfId><%= row.Cells(6).Value %></PmtInfId>
                         <PmtMtd><%= row.Cells(7).Value %></PmtMtd>
                         <BtchBookg><%= row.Cells(8).Value %></BtchBookg>
                         <PmtTpInf>
                             <SvcLvl>
                                 <Cd><%= row.Cells(9).Value %></Cd>
                             </SvcLvl>
                         </PmtTpInf>
                         <ReqdExctnDt><%= row.Cells(10).Value %></ReqdExctnDt>
                         <Dbtr>
                             <Nm><%= row.Cells(11).Value %></Nm>
                             <Id>
                                 <OrgId>
                                     <Othr>
                                         <Id><%= row.Cells(12).Value %></Id>
                                         <Issr><%= row.Cells(13).Value %></Issr>
                                     </Othr>
                                 </OrgId>
                             </Id>
                         </Dbtr>
                         <DbtrAcct>
                             <Id>
                                 <IBAN><%= row.Cells(14).Value %></IBAN>
                             </Id>
                         </DbtrAcct>
                         <DbtrAgt>
                             <FinInstnId>
                                 <BIC><%= row.Cells(15).Value %></BIC>
                             </FinInstnId>
                         </DbtrAgt>
                         <CdtTrfTxInf>
                             <PmtId>
                                 <EndToEndId><%= row.Cells(16).Value %></EndToEndId>
                             </PmtId>
                             <Amt>
                                 <InstdAmt Ccy=<%= row.Cells(18).Value %>><%= row.Cells(17).Value %></InstdAmt>
                             </Amt>
                             <CdtrAgt>
                                 <FinInstnId>
                                     <BIC><%= row.Cells(19).Value %></BIC>
                                 </FinInstnId>
                             </CdtrAgt>
                             <Cdtr>
                                 <Nm><%= row.Cells(20).Value %></Nm>
                             </Cdtr>
                             <CdtrAcct>
                                 <Id>
                                     <IBAN><%= row.Cells(21).Value %></IBAN>
                                 </Id>
                             </CdtrAcct>
                             <Purp>
                                 <Cd><%= row.Cells(21).Value %></Cd>
                             </Purp>
                         </CdtTrfTxInf>
                     </PmtInf>
            header.Add(detail)
        Next
        doc = New XDocument(xmlDecl, header)
        doc.Save(path)
        MsgBox("Export Finished")
I take this result
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
  <CstmrCdtTrfInitn>
    <GrpHdr>
      <MsgId>HHHHHHHHHHHHHHHHHHHHHHHHHH</MsgId>
      <CreDtTm>HHHHHHHHHHHHHHHHHHHHHHH</CreDtTm>
      <NbOfTxs>HH</NbOfTxs>
      <CtrlSum>HHHHH.HH</CtrlSum>
      <InitgPty>
        <Id>
          <OrgId>
            <Othr>
              <Id>HHH</Id>
              <Issr>HHHHH</Issr>
            </Othr>
          </OrgId>
        </Id>
      </InitgPty>
    </GrpHdr>
  </CstmrCdtTrfInitn>

  <PmtInf xmlns="">
    <PmtInfId>DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD</PmtInfId>
    <PmtMtd>DDD</PmtMtd>
    <BtchBookg>DDDDD</BtchBookg>
    <PmtTpInf>
      <SvcLvl>
        <Cd>DDDD</Cd>
      </SvcLvl>
    </PmtTpInf>
    <ReqdExctnDt>DDDDDDDDDD</ReqdExctnDt>
    <Dbtr>
      <Nm>DDDDDDDDDDDD</Nm>
      <Id>
        <OrgId>
          <Othr>
            <Id>DDDDDDDDDDD</Id>
            <Issr>DDDDDDDDDDDDDDDDDDDD</Issr>
          </Othr>
        </OrgId>
      </Id>
    </Dbtr>
    <DbtrAcct>
      <Id>
        <IBAN>DDDDDDDDDDDDDDDDDDDDDDDDDDD</IBAN>
      </Id>
    </DbtrAcct>
    <DbtrAgt>
      <FinInstnId>
        <BIC>DDDDDDDDDDD</BIC>
      </FinInstnId>
    </DbtrAgt>
    <CdtTrfTxInf>
      <PmtId>
        <EndToEndId>DDDDDDDDDDD</EndToEndId>
      </PmtId>
      <Amt>
        <InstdAmt Ccy="EUR">DDD.DD</InstdAmt>
      </Amt>
      <CdtrAgt>
        <FinInstnId>
          <BIC>DDDDDDDDDDD</BIC>
        </FinInstnId>
      </CdtrAgt>
      <Cdtr>
        <Nm>DDDDDDDDDDD</Nm>
      </Cdtr>
      <CdtrAcct>
        <Id>
          <IBAN>DDDDDDDDDDDDDDDDDDDDDDDDDDD</IBAN>
        </Id>
      </CdtrAcct>
      <Purp>
        <Cd>DDDDDDDDDDDDDDDDDDDDDDDDDDD</Cd>
      </Purp>
    </CdtTrfTxInf>
  </PmtInf>
</Document>
I would like to know
1) if it is possible all the details <PmtInf></PmtInf> get inserted before </CstmrCdtTrfInitn> and not after
2) change the <PmtInf xmlns=""> to <PmtInf>

Thanks and regards...