I want my form to store data about imported XML files in a repeating table. New information should go in a new row, but my code always replaces the existing row with the new data.
The schema is
SAN (root)
|-- my:ConstantVariables (group)
|-- my:LassoCollections (group)
|-- my:LassoCollection (repeating group)
|-- my:LassoFileName
|-- my:LassoBuildVersion
The data I want to store in LassoFileName and LassoBuildVersion is stored in strLassoXMLFile and strLassoXMLVersion.
The new XmlDocument "doc" I am making contains the following XML when the code is run:
<my:LassoCollection xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-03-16T10:53:27">
<my:LassoFileName>Lasso_Northern_Lakes_Colle_Collect_Output_20120420_115048_GMT-700.xml</my:LassoFileName>
<my:LassoBuildVersion>4.1</my:LassoBuildVersion>
</my:LassoCollection>
This looks correct to me.
Here is the code that doesn't work:
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement("my:LassoCollection", NamespaceManager.LookupNamespace("my"));
XmlNode fileField = doc.CreateElement("my:LassoFileName", NamespaceManager.LookupNamespace("my"));
XmlNode fileNode = group.AppendChild(fileField);
fileNode.InnerText = strLassoXMLFile;
XmlNode versionField = doc.CreateElement("my:LassoBuildVersion", NamespaceManager.LookupNamespace("my"));
XmlNode versionNode = group.AppendChild(versionField);
versionNode.InnerText = strLassoXMLVersion;
doc.AppendChild(group);
MainDataSource.CreateNavigator().SelectSingleNode("/SAN/my:ConstantVariables/my:LassoCollections", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
What am I doing wrong here?
Paul