I want to add a node named list under product node.
code in xaml is:
<Window.Resources>
<XmlDataProvider x:Name="myDP" x:Key="MyData" Source="Product.xml" XPath="products"
IsAsynchronous="False" IsInitialLoadEnabled="True"
PresentationTraceSources.TraceLevel="High">
</XmlDataProvider>
</Window.Resources>
the addIdtm_button is:
private void addItem_Click_1(object sender, RoutedEventArgs e)
{
try
{
XmlDataProvider provider = (XmlDataProvider)this.FindResource("MyData");
XmlNode elmnt = provider.Document.CreateElement("item");
elmnt.InnerText = itemTextBox.Text;
provider.Document.ChildNodes[0].AppendChild(elmnt);
}
catch (Exception d)
{
MessageBox.Show(d.Message);
}
}
When button is clicked, the MessageBox is displayed: "The current node cannot contain other nodes."
what can I do now???
first
second
third
fourth