You receive an error message if you try to programmatically set the text value of an XML node in InfoPath 2003 (826998)
The information in this article applies to:
- Microsoft Office InfoPath 2003
- Microsoft Office InfoPath 2003, Service Pack 1 (SP1)
SYMPTOMSIf you try to programmatically set the text value of an XML node, you might receive the following error message: A run-time error has occurred. Do you want to debug?
The following error occurred: '#PCDATA' is in nil content. CAUSEThis error is generated when you try to programmatically set the text value of an XML node that has the xsi:nil="true" attribute. When this attribute is set to true, any text value of the XML node produces XML that is not valid. Therefore, Microsoft Office InfoPath does not accept the value, and you receive the error message.WORKAROUNDTo work around this problem, add code that checks for the xsi:nil="true" attribute and then removes the attribute (if the attribute is found) at run time before the code sets the text value of the node. For example, replace the following code: {
// Receive a reference to the element to be filled.
var objDataElement = XDocument.DOM.selectSingleNode("/my:myFields/my:field1");
//Set the value of the element.
objDataElement.text = "10.0";
} with: {
// Receive a reference to the element to be filled.
var objDataElement = XDocument.DOM.selectSingleNode("/my:myFields/my:field1");
//Determine whether the xsi:nil attribute is set for this
//element. If so, remove the xsi:nil attributes so that
//the value can be set.
if (objDataElement.getAttribute("xsi:nil"))
objDataElement.removeAttribute("xsi:nil");
//Set the value of the element.
objDataElement.text = "10.0";
} REFERENCES
For additional information about how to debug script, click the following article number to view the article in the Microsoft Knowledge Base:
827002
How to debug a script for a Microsoft Office InfoPath 2003 form
Modification Type: | Minor | Last Reviewed: | 8/19/2004 |
---|
Keywords: | kbprb kberrmsg KB826998 kbAudDeveloper |
---|
|