Hi all, i have a problem to preserve the whitespaces when append a string to the DOM object. belows is my coding:
Code:
Dim objDOM As New DOMDocument40
Dim nodeOne As IXMLDOMElement
objDOM.preserveWhiteSpace = True
Set nodeOne = objDOM.createElement("TestNode")
nodeOne.nodeTypedValue = Chr(13) & Chr(13) & Chr(10) & Chr(10) & Chr(32) & Chr(9) & " hello " & _
Chr(10) & Chr(10) & Chr(13) & Chr(13) & Chr(10) & Chr(32) & Chr(9) & _
"?" & Chr(13) & Chr(10) & Chr(32)
When i retrieve back the nodeOne value(1 character by 1 character), the charcter Chr(13) is missing. To solve that problem, i assign the node data type to "string" as shown as below:
Code:
nodeOne.dataType = "string"
Now, all the characters(including character Chr(13) and Chr(10)) between "Hello" and "?" are preserved, but all the leading and tailing white spaces characters, Chr(13), Chr(10), Chr(9), Chr(32). It seems like 'Trim' function in
VB.
Can someone please help me to solve the problem?