title: XML how to insert a newline after PCDATA
body: <p>I'm totally new to XML; I just started to study something for my culture using VB6 (! I know... !), without a real goal at the moment. In my first attempt I got a surprising good result, but there is a minor problem which only impact on the visual output. The first line of the XML file is a standard preamble:   <code>?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?</code>. The second line is the node <code>DB</code> info and it should follow the preamble on a new line, in this way:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;
  &lt;DB&gt;Created on 15/06/2021&lt;/DB&gt;
  </code></pre>
  <p>But instead this second line continues on the first. I tried to insert a text node with a newline (as seen on this site), but I get an error, which translated, say something as: &quot;'impossible to execute the operation with a node of type PCDATA&quot;. My code is:</p>
  <pre><code>Sub MakeDB()
  Dim dom As MSXML2.DOMDocument60
  Dim root As IXMLDOMElement
  Dim node As MSXML2.IXMLDOMNode
  
     Set dom = New MSXML2.DOMDocument60
     dom.async = False
     dom.preserveWhiteSpace = True
     
     Set node = dom.createProcessingInstruction(&quot;xml&quot;, &quot;version='1.0' encoding='iso-8859-1'&quot; + vbNewLine)
     dom.appendChild node
     Set node = Nothing
  'the following lines raise the error 
     Set node = dom.createTextNode(vbNewLine)
     dom.appendChild node
     Set node = Nothing
  
  ' Create the first element.
      Set root = dom.createElement(&quot;DB&quot;)   
      Set node = dom.createTextNode(&quot;Created on &quot; + CStr(Date))
      root.appendChild node
      Set node = Nothing
      dom.appendChild root
      ...
  </code></pre>
  <p>I realize that this is not a real problem, but I would like to understand what happens.</p>