XmlDocument counter = new XmlDocument();        XmlNode contype = counter.CreateElement("contype");
        XmlAttribute imgurl = counter.CreateAttribute("imgurl");
        imgurl.Value = "3.gif";
        contype.Attributes.Append(imgurl);        XmlNode Type = counter.CreateElement("Type");
        Type.InnerText = "today";
        contype.AppendChild(Type);     
      this.TextBox1 .Text =counter.InnerXml.ToString () ;为什么都不显示啊 ,counter.InnerXml.ToString () 为null。
这个必须先 counter.load(aa.xml)吗;一定得写到文本里吗?不能在内存中生成再tostring出来吗?不明白

解决方案 »

  1.   

    你没有把你Create的Element添加到counter里面,加上就可以了。XmlDocument counter = new XmlDocument();XmlNode contype = counter.CreateElement("contype");
    XmlAttribute imgurl = counter.CreateAttribute("imgurl");
    imgurl.Value = "3.gif";
    contype.Attributes.Append(imgurl);XmlNode Type = counter.CreateElement("Type");
    Type.InnerText = "today";
    contype.AppendChild(Type);// Only appended node can be disply at InnerXml
    counter.AppendChild(contype);this.textBox1.Text = counter.InnerXml.ToString();