I wanted to do exactly the same as you proposed but this does not work. The bold marked line is the problem. In the debug window both InnerXml properties seem to be the same!? Why can't I set it this way?
System.Xml.XPath.XPathNavigator fieldxpn;
// the new values in the drop down list
String[] newItems = { "11111", "22222222", "33333333" };
// create a new XML document
XmlDocument newXdoc = new XmlDocument();
XmlElement colNames = newXdoc.CreateElement("ColumnNames");
newXdoc.AppendChild(colNames);
foreach (String s in newItems)
{
XmlElement colName = newXdoc.CreateElement("ColumnName");
colName.InnerText = s;
colNames.AppendChild(colName);
}
fieldxpn = DataSources["participantFields"].CreateNavigator();
// ERROR: why does this not work?
// -> "Unexpected XML declaration. The XML declaration
// must be the first node in the document,
// and no white space characters are allowed to appear before it.
// Line 1, position 9."
fieldxpn.InnerXml = newXdoc.InnerXml;