Hey,
You are right. In addition to that it turns that you cannot even replace the outer XML of the navigator of the data object so that solution would not work either.
This problem got me curious so I did some debugging and found a hack that will allow you to do what you need. This involves getting access to the underlying document from the navigator and using it to inject the PIs.
--- Note: this solution requires Full Trust ---
First of all, you will need to add a reference to the IP2003 OM assembly:
C:\Program Files\Microsoft Office\Office12\Microsoft.Office.Interop.InfoPath.SemiTrust.dll
Now let's get to the document:
XPathNavigator receiveFormY = DataSources["receiveFormY"].CreateNavigator();
// Get the Microsoft.Office.InfoPath.MsxmlNavigator's member WrappedXmlNode
IXMLDOMDocument2 document = (IXMLDOMDocument2)receiveFormY.GetType().InvokeMember("WrappedXmlNode", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, receiveFormY, new object[] { });
At this point you are holding a fully functional IP2003 document and you can edit it as you please. For example:
IXMLDOMNode piNode = document.createProcessingInstruction(piName, piValue);
document.insertBefore(piNode, document.documentElement);
Once you're done editing, just call Submit() as before:
ySubmit.Execute(receiveFormY);
I am sorry I could not find a more elegant solution for you but this one seems to work (besides the Full Trust requirement). Good luck!
David Airapetyan / Software Services ArchitectQdabra® Software / Streamline data gathering to turn process into knowledge