I'm using a MXXMLWriter60 in combination with a SAXXMLReader60 to indent the output and add the correct encoding tag.
The output content is indented but it seems like the encoding property is always ignored. Why?
Input, loaded via DOMDocument60.Load(), looks like:
<?xml version="1.0" encoding="iso-8859-15"?>
Sourcecode:
Private Sub SaveXmlAs(ByVal thisDOMDocument60 As DOMDocument60, ByVal thisEncoding As String, ByVal thisDestinationPath As String)
' Set properties on the XML writer - including BOM, XML declaration and encoding
Dim xmlWriter As New MXXMLWriter60
With xmlWriter
.Encoding = "iso-8859-15"
'.Version = "1.0"" encoding=""iso-8859-15" Hacky solution like hell...
.byteOrderMark = True
.omitXMLDeclaration = False
.indent = True
End With
' Set the XML writer to the SAX content handler.
Dim xmlReader As New SAXXMLReader60
With xmlReader
Set .contentHandler = xmlWriter
Set .dtdHandler = xmlWriter
Set .errorHandler = xmlWriter
' Now pass the DOM through the SAX handler, and it will call the writer
.Parse thisDOMDocument60
End With
' Let the writer do its thing
Open thisDestinationPath For Output As #1
Print #1, xmlWriter.output
Close #1
End Sub
The output always looks like:
<?xml version="1.0" standalone="no"?>