protected void WriteGiftInfoXml()
{
            XmlDocument XDoc = new XmlDocument();
            XDoc.LoadXml("<GiftInfo></GiftInfo>");
            //设置版本信息
            XmlDeclaration xmldecl;
            xmldecl = XDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            XmlElement root = XDoc.DocumentElement;
            XDoc.InsertBefore(xmldecl, root);

            //设置根节点
            XmlElement newGiftInfo = XDoc.DocumentElement;
            //创建礼品ID的节点
            XmlElement newGiftId = XDoc.CreateElement("GiftId");
            newGiftId.InnerText = "1001";     
            newGiftInfo.AppendChild(newGiftId);

            //创建礼品分类ID的节点
            XmlElement newCategoryId = XDoc.CreateElement("CategoryId");
            newCategoryId.InnerText = "Bless";       //礼品分类ID
            newGiftInfo.AppendChild(newCategoryId);


            XmlTextWriter tw = new XmlTextWriter(NewGiftFileAddress + GiftId + ".xml", System.Text.Encoding.UTF8);
            XDoc.WriteContentTo(tw);
            tw.Close();
}

相关文章:

  • 2021-10-21
  • 2021-08-25
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2022-01-25
  • 2022-12-23
  • 2022-01-01
  • 2022-01-01
  • 2021-12-26
相关资源
相似解决方案