If a node is an optional in the xml and in the Infopath UI then then that node will not be present in the XML by default. You can add this node in the code, when you add this node in the code that optional field will be seen in the UI.
Here is the sample to add a Node
string sXml = "<my:group1 xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-13T11:32:39'><my:field1/></my:group1>";
IXMLDOMDocument oXml = thisXDocument.CreateDOM();
oXml.async = false;
oXml.loadXML(sXml);
getNode("//my:myFields").appendChild(oXml.documentElement);
Agni
InfopathDev India