i am writing a simple code in JScript to update Main xml schema.
structure of my Main data source schema is as shown below:
myFields -> Company -> Name
where myFields is the default root element in the Main data source. Company is a simple group and Name is text string.
Now, below is the simple JSript code to update the Main xml schema:
function load::OnClick(eventObj)
{
var mainRoot = XDocument.DOM.selectSingleNode("/my:myFields");var myXML = "<my:Company xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-01-28T10:22:49'>"
+ "<my:Name>HCL</my:Name>"
+ "</my:Company>";
var domNewRow = XDocument.CreateDOM();
domNewRow.validateOnParse =
false;domNewRow.async = false;
domNewRow.loadXML(myXML);
domNewRow.setProperty("SelectionNamespaces", 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-01-28T10:22:49"');
mainRoot.appendChild(domNewRow.selectSingleNode("my:Company"));
}
The following error occurred on previewing the form:
Element '{http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-01-28T10:22:49}Company' is unexpected according to content model of parent element '{http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-01-28T10:22:49}myFields'.
please help me out in resolving the issue.