A small workaround:
Code: Select all
Procedure SaveBeautifyXML(XMLId.l, XMLFile$)
  Protected i, Lpos, Rpos = 1, pos = 1, indent = 0, tag$ = "", ntag, xml$, new$, encoding$
  If IsXML(XMLId)
    xml$ = Space(ExportXMLSize(XMLId))
    ExportXML(XMLId, @xml$, Len(xml$))
    xml$ = RemoveString(xml$, Chr(13))
    For i=1 To CountString(xml$, "<")
      Lpos = FindString(xml$, "<", Rpos)
      Rpos = FindString(xml$, ">", Lpos)
      ntag$ = Mid(xml$,Lpos, Rpos-Lpos+1)
      If tag$="" ; <?xml version="1.0" encoding="UTF-8"?>
        new$ = ntag$
        If FindString(ntag$, "UTF-8",1)
          encoding$ = "UTF-8"
        EndIf
        indent - 2
      ElseIf Left(tag$,2) <> "</" And Left(ntag$,2) = "</" ; <Tag></Tag>
        txt$ = Trim(Mid(xml$, pos, Lpos-pos))
        If Left(txt$,1) = #LF$
          txt$ = Trim(Mid(txt$,2))
        EndIf
        If Right(txt$,1) = #LF$
          txt$ = Trim(Left(txt$,Len(txt$)-1))
        EndIf
        new$ + txt$ + ntag$ 
      Else
        If Left(tag$,2) = "</" And Left(ntag$,2) = "</" ;  ; </Tag2></Tag1>
          indent - 2
        ElseIf Left(tag$,2) <> "</" And Left(ntag$,2) <> "</" ;  ; <Tag1><Tag2>
          indent + 2
        EndIf
        new$ + #LF$ + Space(indent) + ntag$
      EndIf
      tag$ = ntag$
      pos = Rpos+1
    Next
    If CreateFile(0, XMLFile$)
      If encoding$ = "UTF-8"
        WriteStringFormat(0, #PB_UTF8)
        WriteString(0, new$, #PB_UTF8)
      Else
        WriteString(0, new$)
      EndIf
      CloseFile(0)
    EndIf
  EndIf
EndProcedure
If LoadXML(1, "address.xml")
  SaveBeautifyXML(1, "adress.xml")
  FreeXML(1)
EndIf
 
Before:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Adressen Anzahl="1">
  <Adresse id="1">
    <Name>
      Thorsten Hoeppner
    </Name>
    <Strasse>
      Alte Zeile 18
    </Strasse>
    <Ort>
      87600 Kaufbeuren
    </Ort> 
  </Adresse>
</Adressen>
 
After:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Adressen Anzahl="1">
  <Adresse id="1">
    <Name>Thorsten Hoeppner</Name>
    <Strasse>Alte Zeile 18</Strasse>
    <Ort>87600 Kaufbeuren</Ort>
  </Adresse>
</Adressen>