XML DOM - Processing Instructions
I'm having problems when using XML DOM to create XML documents because I want to specify a particular encoding and it doesn't appear to let me:
Code:
Dim xmlDoc As MSXML2.DOMDocument40
Dim pi As MSXML2.IXMLDOMProcessingInstruction
Set xmlDoc = New MSXML2.DOMDocument40
Set pi = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding= 'ISO-8859-1'")
xmlDoc.appendChild pi
But in my generated document, it looks like this:
<?xml version="1.0" ?>
i.e. there is no encoding attribute.
Re: XML DOM - Processing Instructions
Are you looking at the actual created xml document or are you looking at the xml from within your app via debug? I ask beacuse you won't see the encoding in your app but the output xml file will (at least should) contain it.
Re: XML DOM - Processing Instructions
No, it's actually the other way around. The XML within the app via debug is fine. It is the outputted document that has lost the "encoding" attribute.
Re: XML DOM - Processing Instructions
Are you doing a save? E.g. the following which works perfectly for me.
Code:
Dim xmlDoc As MSXML2.DOMDocument40
Dim pi As MSXML2.IXMLDOMProcessingInstruction
Set xmlDoc = New MSXML2.DOMDocument40
Set pi = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding= 'ISO-8859-1'")
xmlDoc.appendChild pi
xmlDoc.save "C:\temp\test.xml"