From 4703b7bac13a6799e7f4221cfdbbdfc1e6303a67 Mon Sep 17 00:00:00 2001 From: bclothier Date: Thu, 19 Oct 2023 18:17:33 -0500 Subject: [PATCH] Add a check when loading XML and verify it was successfully parsed. This avoid generating a bad export where the data are not actually exported due to invalid XML being generated by Application.ExportXML. Unfortunately, if a table contains any characters that aren't valid for XML document, it won't try to escape them and include them as literals. Even if they were escaped, they might not be accepted anyway. XML specifications forbids having any characters in 0x01-0x31 range so if a table data contains such characters, this can cause the XML export to fail. In this case, tab delimited will have to be used instead. However, the previous version was simply silently exporting as if everything is hunky-dory when it's not. Hence, the error. --- Version Control.accda.src/modules/modSanitize.bas | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Version Control.accda.src/modules/modSanitize.bas b/Version Control.accda.src/modules/modSanitize.bas index 2e284b39..c84f2a70 100644 --- a/Version Control.accda.src/modules/modSanitize.bas +++ b/Version Control.accda.src/modules/modSanitize.bas @@ -618,7 +618,11 @@ Public Function SanitizeXML(strPath As String, blnReturnHash As Boolean) As Stri Set objXml = New MSXML2.DOMDocument60 End If - objXml.LoadXML strFile + If objXml.LoadXML(strFile) = False Then + Log.Error eelError, _ + "Unable to parse the XML for file '" & strPath & "'. This may be due to containing malformed XML. Check the source XML document for validity. In some cases, this may be due to table data containing characters not allowed in XML documents.", ModuleName & ".SanitizeXML" + Exit Function + End If ' Determine if it's a table data with schema For Each objNode In objXml.SelectNodes("/root/dataroot")