M
mauricecosgrave
Hi all,
I need to create an XML file that has multiple instances of elements,
such as
<play>
<name></name>
<form></form>
<set></set>
</play>
<play>
<name></name>
<form></form>
<set></set>
</play>
The idea is that the user can create multiple plays in the xml file.
What's the best way to do this? I create one instance of the elements
with the following code:
play = xmldoc.CreateElement("play");
global.AppendChild(play);
name = xmldoc.CreateElement("name");
xmltext = xmldoc.CreateTextNode(currentPlayNameTextBox.Text);
name.AppendChild(xmltext);
play.AppendChild(name);
form = xmldoc.CreateElement("form");
xmltext =
xmldoc.CreateTextNode(formSelComboBox.SelectedItem.ToString());
form.AppendChild(xmltext);
play.AppendChild(form);
set = xmldoc.CreateElement("set");
mltext = xmldoc.CreateTextNode(setSelComboBox.SelectedItem.ToString());
set.AppendChild(xmltext);
play.AppendChild(set);
but if I try to just repeat this I get an error saying "This document
already has an 'XmlDeclaration' node.".
Any help would be much appreciated. Thanks.
Maurice
I need to create an XML file that has multiple instances of elements,
such as
<play>
<name></name>
<form></form>
<set></set>
</play>
<play>
<name></name>
<form></form>
<set></set>
</play>
The idea is that the user can create multiple plays in the xml file.
What's the best way to do this? I create one instance of the elements
with the following code:
play = xmldoc.CreateElement("play");
global.AppendChild(play);
name = xmldoc.CreateElement("name");
xmltext = xmldoc.CreateTextNode(currentPlayNameTextBox.Text);
name.AppendChild(xmltext);
play.AppendChild(name);
form = xmldoc.CreateElement("form");
xmltext =
xmldoc.CreateTextNode(formSelComboBox.SelectedItem.ToString());
form.AppendChild(xmltext);
play.AppendChild(form);
set = xmldoc.CreateElement("set");
mltext = xmldoc.CreateTextNode(setSelComboBox.SelectedItem.ToString());
set.AppendChild(xmltext);
play.AppendChild(set);
but if I try to just repeat this I get an error saying "This document
already has an 'XmlDeclaration' node.".
Any help would be much appreciated. Thanks.
Maurice