Questo funziona, a parte una cosa: come faccio ad attacare attr3 al nuovo nodo newElem?
qui me lo attacca al mio temporalLine
codice:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<temporalLine>" + "</temporalLine>");
//attributi nodo root
XmlAttribute attr;
attr = doc.CreateAttribute("Start");
attr.Value = this.StartPoint;
doc.DocumentElement.SetAttributeNode(attr);
XmlAttribute attr2;
attr2 = doc.CreateAttribute("Duration");
attr2.Value = this.StopPoint;
doc.DocumentElement.SetAttributeNode(attr2);
// Create a new element node.
foreach (Control c in this.Controls)
{
if (c is PaintRectangle)
{
PaintRectangle pr =(PaintRectangle)c;
XmlNode newElem;
newElem = doc.CreateNode(XmlNodeType.Element, "image", "");
doc.DocumentElement.AppendChild(newElem);
XmlAttribute attr3;
attr3 = doc.CreateAttribute("href");
attr3.Value = pr.Name;
doc.DocumentElement.SetAttributeNode(attr3);
}
}