Hi,
I'm trying to create an XML file from a C# application. I can create
children of the root using this code:
-------------------------------------------------------------
//Save the variables
pbName = selPBTextbox.Text;
pbUnit = unitList.Text;
XmlDocument xmldoc;
XmlNode xmlnode;
XmlElement global; // Global
XmlElement play; // Title of the playbook
XmlText xmltext;
xmldoc = new XmlDocument();
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
xmldoc.AppendChild(xmlnode);
global = xmldoc.CreateElement("", "playbook", "");
xmldoc.AppendChild(global);
play= xmldoc.CreateElement("", "play", "");
xmltext = xmldoc.CreateTextNode(pbName);
play.AppendChild(xmltext);
xmldoc.ChildNodes.Item(1).AppendChild(play);
-------------------------------------------------------------
The problem I'm having is in creating a child of a child, for example
if I wanted to add 'title' and 'unit' to 'play':
<playbook>
<play>
<title></title>
<unit></unit>
</play>
<play>
<title></title>
<unit></unit>
</play>
<play>
<title></title>
<unit></unit>
</play>
</playbook>
how would I go about it? Using the code above won't add the 'title'
and 'unit' elements to the 'play' elements, it will just add them at
the same level as 'play'? As you can see I also need to have multiple
occurances of the 'play' element.