I have several text boxes in my InfoPath form that are defined as double precision, as well as other text boxes that are strings (text).
In VB.net code, I can easily assign the value of a string text box:
thisXDocument.DOM.selectSingleNode("my:node").text = "Whatever"
But, what if I want to assign a numeric value to one of the double numeric text boxes? I looked for something like:
thisXDocument.DOM.selectSingleNode("my:node").
Value = 999
That does not work.
What does work? I kept on getting an error like:
'#PCDATA' is in nil contentIf I changed the text boxes to text (string), then everything worked great. But, I did not want them to be string data. I wanted numbers so I could calculate sums, etc.
After a great deal of search, I found the answer. You have to first remove the "nil attribute". How?
thisXDocument.DOM.selectSingleNode("my:node").attributes.removeNamedItem("xsi:nil") 'all on one line
MicroSoft has a KB article (826998) that describes this in jscript.
http://support.microsoft.com/kb/826998/en-usAdded later (7/3/2006)
After some trial and error, I discovered that if I set the decimal defined text boxes to have a default value (zero in my particular case), then I did not have to worry about the PCDATA is in nil content problem at all. I did not have to remove atribute at all. Setting a default value solved the problem for me.
If you cannot or do not wish to set a default value, or if you are concerned about the user deleting your default, then you need to check to see if there is a nil attribute, then remove it if it is there. That can be done with simple if then end if code.