Reputation: 370
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
Upvotes: 1
Views: 947
Reputation: 11465
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, thexml
property forDOMDocument
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 thexml
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.
Upvotes: 1