- Add the following code to the Clicked event handler of the button:
C#string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild())
{writer.WriteStartElement("group2", myNamespace);writer.WriteElementString("field1", myNamespace, "Cell 1");writer.WriteElementString("field2", myNamespace, "Cell 2");writer.WriteElementString("field3", myNamespace, "Cell 3");writer.WriteEndElement();writer.Close();
}
Visual BasicDim myNamespace As String = NamespaceManager.LookupNamespace("my")
Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _"/my:myFields/my:group1", NamespaceManager).AppendChild()writer.WriteStartElement("group2", myNamespace)writer.WriteElementString("field1", myNamespace, "Cell 1")writer.WriteElementString("field2", myNamespace, "Cell 2")writer.WriteElementString("field3", myNamespace, "Cell 3")writer.WriteEndElement()writer.Close()
End Using - Save, build, and test your work.
Article taken from:
http://www.bizsupportonline.net/infopath2007/programmatically-add-row-repeating-table-xmlwriter.htm
No comments:
Post a Comment