Move newlines outside of XML element tags

Easier to read in both the source code and generated XML.

-- Combine some statements onto a single line

Follow-on from https://pdfium-review.googlesource.com/c/pdfium/+/82290

Change-Id: Iac0f51731ebe59d73d8b4691b16b1d8fee289948
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82510
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 6861a2b..4e3d287 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -31,7 +31,7 @@
              pChild = pChild->GetNextSibling()) {
           Export(pStream, pChild);
         }
-        pStream->WriteString("</xdp:xdp\n>");
+        pStream->WriteString("</xdp:xdp>\n");
         break;
       }
       case XFA_PacketType::Datasets: {
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 6141841..138a13b 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -13,7 +13,6 @@
 #include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/stl_util.h"
 #include "core/fxcrt/xml/cfx_xmlchardata.h"
 #include "core/fxcrt/xml/cfx_xmlelement.h"
 #include "core/fxcrt/xml/cfx_xmlnode.h"
@@ -222,18 +221,10 @@
         if (bodyTagName.IsEmpty())
           bodyTagName = L"ListBox1";
 
-        buf << "<";
-        buf << bodyTagName;
-        buf << " xmlns=\"\"\n>";
-        for (int32_t i = 0; i < fxcrt::CollectionSize<int32_t>(wsSelTextArray);
-             i++) {
-          buf << "<value\n>";
-          buf << ExportEncodeContent(wsSelTextArray[i]);
-          buf << "</value\n>";
-        }
-        buf << "</";
-        buf << bodyTagName;
-        buf << "\n>";
+        buf << "<" << bodyTagName << " xmlns=\"\">\n";
+        for (const WideString& text : wsSelTextArray)
+          buf << "<value>" << ExportEncodeContent(text) << "</value>\n";
+        buf << "</" << bodyTagName << ">\n";
         wsChildren += buf.AsStringView();
         buf.Clear();
       } else {
@@ -292,13 +283,9 @@
     buf << wsName;
     buf << wsAttrs;
     if (wsChildren.IsEmpty()) {
-      buf << "\n/>";
+      buf << "/>\n";
     } else {
-      buf << "\n>";
-      buf << wsChildren;
-      buf << "</";
-      buf << wsElement;
-      buf << "\n>";
+      buf << ">\n" << wsChildren << "</" << wsElement << ">\n";
     }
   }
 }
@@ -477,7 +464,7 @@
     if (wsVersionNumber.IsEmpty())
       wsVersionNumber = L"2.8";
 
-    wsVersionNumber += L"/\"\n>";
+    wsVersionNumber += L"/\">\n";
     pStream->WriteString(wsVersionNumber.ToUTF8().AsStringView());
 
     CXFA_Node* pChildNode = pNode->GetFirstChild();
@@ -485,7 +472,7 @@
       RegenerateFormFile_Container(pChildNode, pStream, false);
       pChildNode = pChildNode->GetNextSibling();
     }
-    pStream->WriteString("</form\n>");
+    pStream->WriteString("</form>\n");
   } else {
     RegenerateFormFile_Container(pNode, pStream, bSaveXML);
   }