开发者

XmlWriter - Writing xsi:nil=true attribute

I have an issue with an InfoPath 2010 form, that has some code behind it. The purpose of my form is to collect data from a user, and using the answers provided, auto populate a number of required tasks. These tasks are populated in a repeating section on the form. My code behind contains the logic to auto populate each entry in the repeating section. I am using the XMLWriter class, and WriteStringElement methods to populate each of the fields in the repeating section.

Initially all of this logic looks to work as expected, the sections are populated as expected. I do however now realise that there is an issue with the fields written into the form XML.

Using a workflow I am generating SharePoint tasks for each of the items in the repeating section. Following task completion I am writing the status an d completion date back into the form. The problem I have is that I obviously don't populate the CompletedDate field when originally setting up the tasks in the form. I assumed that the field would be automatically added to the form XML, with an xsi:nil=true attribute. Instead it's not in the XML at all, and my workflow s throwing an Object Reference not set error when looking for the node "faCompletedDate". Checking the XML of the form, it is not there.

The solution I think I need is to write out an xsi:nil attribute to teh faCompletedDate in the code behind the form, I am not sure how this is done.

I had tried:

writer.WriteStartElement("faCompletedDate", myNs)
writer.WriteAttributeString(开发者_开发技巧"xsi", "nil", xsiNs, "true")
writer.WriteEndElement()

but this throws a schema validation found non-data type error.

Can someone help me address this issue and suggest the best approach to use.


Ok, I managed to resolve this. It appears I had missed the namespace manager parameter in one of my XMlWriter statements. Updating this allowed me to write out the full section(s) as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜