1

I have a very simple PowerBuilder code:

OLEObject lole_DOM
lole_DOM = CREATE OLEObject
lole_DOM.ConnectToNewObject("MSXML2.DOMDocument.4.0")
lole_DOM.LoadXML('<?xml version="1.0" encoding="UTF-8"?><root/>')
MessageBox("", String(lole_DOM.XML))
DESTROY lole_DOM

And the result I get:

<?xml version="1.0"?>
<root/>

Where did encoding attribute go? Not sure who to blame, PowerBuilder or MSXML2.DOMDocument.4.0, any ideas?

Using PowerBuilder version 11.5.1 Build 5097

Valdas
  • 368
  • 4
  • 14

1 Answers1

1

This is by design. As stated in the "Remarks" section of the documentation for the xml property:

The xml property always returns a Unicode string. That is, the xml property for DOMDocument converts the document from its original encoding to Unicode. As a result, the original encoding attribute is removed. For example, <?xml version="1.0" encoding="UTF-8"?> appears in the xml property as follows.

<?xml version="1.0"?>

In constrast, if you save the document into a file with save() you will see that the processing instruction is complete in the file, and the file is encoded accordingly.

Seki
  • 11,135
  • 7
  • 46
  • 70