So I got my first taste of working with the new SharePoint 2010 Managed Client Object Model...and just one exaggerated word: Saw-weeeeeet. I used it to write a module that would programmatically add an attachment to an InfoPath 2007 document stored in SharePoint. Ironically enough, the COM code worked right out of the gate and it was the XML DOM manipulation code that proved the most finicky. It's alot of code so I'm not going to post it all up, but if you have a need to programmatically manipulate InfoPath (XML) documents stored within SharePoint - shoot me an email and I'll send you a code sample.
That said, I thought I'd post a quick blurb about one of the obscure gotchas I encountered on this project. I was seeing the following error when trying to open the InfoPath document in InfoPath Forms Services after making the programmatic changes:
schema validation found non-data type
Initial searching turned up a bunch of articles referring to the xsi:nil attribute, but that was not my issue. In fact, I used a text editor to compare the 2 files (an XML document created in InfoPath Forms Services and an XML document modified by my programmatic code) - disregarding case and spacing, and they were identical! However I realized that a couple of the tags in the programmatically saved document had a line feed inserted between their opening tag and closing tag, and more importantly - removing the line feeds fixed the problem! (The fact that trivial white-space was capable of invalidating InfoPath's schema is a testimony to its instability in my opinion, but whatever - job security, right?)
That fixed it...and I blogged it ;-)