我将如何写出xml
<?xml version="1.0" encoding="UTF-8"?>
<calibration>
<ZoomLevel 250>0.0100502512562814</ZoomLevel 250>
<ZoomLevel 250>0.0100502512562814</ZoomLevel 250>
........
</calibration>
我知道如何写出来,但我不能在一个循环中写出来,我需要 atm 我有写 xml 表是
public void XMLWrite(Dictionary<string, double> dict)
{
//write the dictonary into an xml file
XmlDocument doc = new XmlDocument();
XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(docNode);
XmlNode productsNode = doc.CreateElement("calibration");
doc.AppendChild(productsNode);
foreach (KeyValuePair<string, double> entry in dict)
{
XmlNode zoomNode = doc.CreateElement("ZoomLevel");
XmlAttribute ZoomLevel = doc.CreateAttribute(entry.Key.ToString());
//XmlElement PixelSize = doc.CreateElement (entry.key = entry.Value.ToString());
zoomNode.Attributes.Append(ZoomLevel);
productsNode.AppendChild(zoomNode);
}
doc.Save(pathName);
}