1

I have an XML file that I'm trying to update. The section in question is text intended for consumption by humans. In order to improve readability it needs to have paragraphs and, for that, carriage returns / line feeeds.

In the original file, a carriage return / line feed is represented by the following characters - "
". These characters seem to be required by this XML file's application in order to display the content accurately.

XML File

Without the right characters in the XML, the content paragraphs just all run on and create a big block of text that isn't easy to consume.

I'm working with Microsoft Word VBA. I'm puling the content for the XML file from a Content Control (which I think is irrelevant because it's simply returning a string).

Despite the content in the content control having paragraphs, the content in the application has no CR/LF in it.

Text in Word Application

Text in the XML application

To date, I've tried simply adding the characters (ie "
") into the string, but that didn't work. I've tried to add chr(10) and chr(13) directly into string, and a host of other options, but to no avail.

Thank you in advance for any support, tips or ideas that you can provide.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • In terms of XML parsing it doesn't matter whether there is a literal character or a decimal or hexadecimal character reference in an element node's markup content. You haven't shown us any VBA code that tries to manipulate XML but usually VBA uses some version of MSXML and its DOM to do that. There you would then set the `.text` property of an element node to a string with the newline/carriage return characters. Inserting character references isn't something the MSXML DOM supports as the `.xml` property is read-only. – Martin Honnen Jan 09 '23 at 21:13
  • Even if it had a setter it would use an XML parser to parse the character reference into the character. – Martin Honnen Jan 09 '23 at 21:14

0 Answers0