我想把本页面中的Lable中的内容写入到xml文档中。麻烦各位高人了!!  谢谢!

解决方案 »

  1.   

    有一个简单的方法
    把LABLE读到DataTabel中,然后用DataTabel生产XML
      

  2.   

    补充下
    用DT中的WriteXml方法生成XML
      

  3.   

    public void Insert(string path, string node, string element, string attribute, string value)
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(path);
                    XmlNode xn = doc.SelectSingleNode(node);
                    if (element.Equals(""))
                    {
                        if (!attribute.Equals(""))
                        {
                            XmlElement xe = (XmlElement)xn;
                            xe.SetAttribute(attribute, value);
                        }
                    }
                    else
                    {
                        XmlElement xe = doc.CreateElement(element);
                        if (attribute.Equals(""))
                        {
                            xe.InnerText = value;
                        }
                        else
                        {
                            xe.SetAttribute(attribute, value);
                        }
                        xn.AppendChild(xe);
                    }
                    doc.Save(path);
                }
                catch { }
            }