Element is unexpected according to content model of parent element

N

Neha

I was trying to create a node under myFields node of a infopath form
programatically. The code for the same is:
public partial class ThisAddIn
{
private Microsoft.Office.Interop.InfoPath._Application3 App; void
ThisAddIn_Startup(object sender, System.EventArgs e)
{
App = (Microsoft.Office.Interop.InfoPath._Application3)this.Application;
Microsoft.Office.Interop.InfoPath._XDocument3 doc =
(Microsoft.Office.Interop.InfoPath._XDocument3)App.XDocuments.NewFromSolution(@"C:\Documents and Settings\neha.mittal\Desktop\BlankTemplate.xsn");

try{
IXMLDOMNode nodeEntry = tempDom.childNodes[3]; // returns myFields Node
IXMLDOMDocument2 tempDom = (IXMLDOMDocument2)doc.DOM;
private Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMNode childNode =
nodeEntry.ownerDocument.createNode("element", "myFields:Designation",
nodeEntry.namespaceURI);
nodeEntry.appendChild(childNode);catch (Exception ex) {}
}
}

But when i try to Append() my childNode in Parent Node(nodeEntry) it gives
following rumtime error:

Element
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-18T12:29:35}Designation'
is unexpected according to content model of parent element
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-18T12:29:35}myFields'.

Please suggest some work arround for the above problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top