You can generate form XML template by opening xsn then saving blank form.
Then you can load that up as XmlDocument and work with XmlDocument by
accessing elements using a combination of DOM and XPath and populate InnerXml
or InnerText from whatever datasources you choose. I am working with
Strongly Typed Datasets in VS2005.
Quick sample on how you can load XML from file into XmlDocument
xml_string is the location of your file:
XmlTextReader xtr = new XmlTextReader(new StringReader(xml_string));
xtr.Read();
xmlDocument.Load(xtr);
This is how you could access the Xml elements:
XmlNodeList lisp = doc.GetElementsByTagName("mstns:LisPendantsList");
this would get you the top complex type elements and by accessing and
scrolling through XmlNodeList you can access InnerXml or InnerText property.
Loading blank form will save you the hassle in dealing with namespaces.
Hope this helps.

Signature
Boris Kleynbok
Web Developer
DotComFactory
> I am collecting data though a C# program and I would like to be able to
> programmatically create an InfoPath form. I found a way to do it in JScript
[quoted text clipped - 18 lines]
>
> Andrew
Andrew - 30 Dec 2005 14:20 GMT
The only fear I have in doing that is if the user drammically changes the
xsn form without saving a new xml template or really if they change anything
at all since the namespace will be different now between the template xml
file and the XSN file.
NameSpace manager isn't all that bad. Since I really knew nothing about
XML before InfoPath it did take a little bit, but here is some code for
getting the namespace manager and prefix out of the InfoPath xml doc. It's
in C#
#region Get name space
public XmlNamespaceManager GetNamespaces(XmlDocument xmlDoc)
{
XmlNode node1 = xmlDoc.DocumentElement;
XmlNamespaceManager manager1 = new
XmlNamespaceManager(xmlDoc.NameTable);
int num1 = 4;
XmlNode node2 = node1.Attributes.Item(num1);
string text1 = node2.LocalName;
string text2 = node1.Attributes.Item(num1).Value;
manager1.AddNamespace(text1,text2);
return manager1;
}
#endregion
Thanks,
Andrew
> You can generate form XML template by opening xsn then saving blank form.
> Then you can load that up as XmlDocument and work with XmlDocument by
[quoted text clipped - 41 lines]
> >
> > Andrew