I have the following structure (simplified for this illustraion):
my:Fields
my:Results
jobid
address
postcode
my:Activity
type
serialnum
action
I am trying to dynamically call a stored procedure to produce the my:Activity elements if the jobid from my:Results returns any elements when calling the stored procedure with the jobid value.
See my code below (which is called after the user has selected a row and clicked on a button):
var jobid = eventObj.Source.selectSingleNode("my:jobid").text
XDocument.DataAdapters("JobColl").Command = "execute getJobActivity "+ jobid;
XDocument.DataAdapters("JobColl").Query();
var jobResults = XDocument.GetDOM("JobCol").getElementsByTagName("d:JOBCOL");
for(var j=1;j<jobResults.length+1;j++)
{
var oNode = XDocument.DOM.selectSingleNode("/dfs:myFields/my:Results/my:Activity");
oNode = oNode.cloneNode(true);
oNode.selectSingleNode("my:serialnum").text = XDocument.GetDOM("JobCol").selectSingleNode("/dfs:myFields/dfs:dataFields/d:JOBCOL["+j+"]/@jbcl_serialnum").text;
parent = XDocument.DOM.selectSingleNode("/dfs:myFields/my:Results");
parent.appendChild(oNode);
}I tried to make the parent the individual element of my:Results corresponding to the job id e.g.
parent = XDocument.DOM.selectSingleNode("/dfs:myFields/my:Results[ntlid="+jobid+"]");
However it stated that the value was null or not an object.
However when trying to add the oNode to the Parent I get the following error:
Element {http://schemas.... } 'Activity' is unexpected according to the content model of parent element
{http://schemas... } 'Results' The format is correct though, does anybody see anything obvious.
Many Thanks