Okay, thanks. I'm on the right track now...but still getting some errors. See my comments to the right of the code.
The xml file is called PatientData.xml and I created a datasource called PatientData that references the xml file.
RemoveItems("PatientData");
foreach (DataRow dataRow in patientTable.Rows)
{
string PatientID = dataRow.Item[patientId].toString(); // here and on the next line I'm getting an error at the .Item part of dataRow.Item[... the error: System.data.datarow doesn't contain a definion for Item
string PatientLName = dataRow.Item[patientLastName].toString();
AddItem(PatientID, PatientLName, PatientData); // and here I get the error: the name PatientData does not exist in the current context
}
... then...
private void RemoveItems(string dataConnection)
{
XPathNavigator DOM = DataSources[dataConnection].CreateNavigator();
XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager); while (group1.MoveToFirstChild())
{
group1.DeleteSelf();
}
}
private void AddItem(string itemId, string itemName, string dataConnection)
{
XPathNavigator DOM = DataSources[dataConnection].CreateNavigator();
XPathNavigator DOM2 = DataSources["PatientData"].CreateNavigator();
XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);
XPathNavigator field1 = DOM2.SelectSingleNode("//options/option", NamespaceManager);
XPathNavigator newNode = field1.Clone();
newNode.SelectSingleNode("value").SetValue(itemId);
newNode.SelectSingleNode("displayname").SetValue(itemName);
group1.AppendChild(newNode);
}