For those times when you want to take the XML of an InfoPath form and create a Stream object from it, you can use the MemoryStream class for this as shown in the following C# code:
XPathNavigator root = MainDataSource.CreateNavigator();
string formXml = root.SelectSingleNode(
"my:myFields", NamespaceManager).OuterXml;
System.IO.MemoryStream ms =
new System.IO.MemoryStream(
System.Text.Encoding.UTF8.GetBytes(formXml));
Or you can use the following Visual Basic code:
Dim root As XPathNavigator = MainDataSource.CreateNavigator()
Dim formXml As String = root.SelectSingleNode( _
"my:myFields", NamespaceManager).OuterXml
Dim ms As System.IO.MemoryStream = _
New System.IO.MemoryStream( _
System.Text.Encoding.UTF8.GetBytes(formXml))
where my:myFields is the root node of the InfoPath form.
