Cannot Get Whitespace Characters
Posted: Fri Jan 27, 2006 12:02 pm
I have a problem to get the content's characters using DOM object in VB. Belows are my coding:
When i retrieve back the content(one chanracter by one character) from nodeOne, the character Chr(13) has missing.
Because of that, i add a line of coding to assign the node data type to "string" as shown as belows:
now, the characters Chr(13) is preserved but the problem now is all the whitespaces infront of "Hello" and all the whitespaces after the character "?" has missing. It seems like 'Trim' function in VB.
Can someone know how to preserve all the whitespaces, please reply my message.
Thank you.
Code: Select all
Dim objDOM As New DOMDocument40
Dim nodeOne As IXMLDOMElement
objDOM.preserveWhiteSpace = True
Set nodeOne = objDOM.createNode("element", "TestNode", "")
nodeOne.nodeTypedValue = Chr(13) & Chr(10) & Chr(32) & Chr(9) & " hello " & _
Chr(10) & Chr(13) & Chr(32) & Chr(9) & _
"?" & Chr(13) & Chr(10) & Chr(32)
Because of that, i add a line of coding to assign the node data type to "string" as shown as belows:
Code: Select all
nodeOne.dataType = "string"
Can someone know how to preserve all the whitespaces, please reply my message.
Thank you.