<outer_id action="delete">10243</outer_id> xml输出这样的格式,请问写入的时候该怎么写?谢谢

解决方案 »

  1.   


    <outer_id action="delete">"+ 你的值 +"</outer_id> 
      

  2.   

    往网站根目录下test.xml文件里第一个person元素下插入<outer_id action="delete">10243</outer_id>
    XmlDocument xml = new XmlDocument();
    xml.Load(Server.MapPath("~/test.xml"));
    XmlNode person= xml.GetElementsByTagName("person")[0];
    XmlElement newElement = xml.CreateElement("outer_id");
    newElement.SetAttribute("action", "delete");
    newElement.InnerText = "10243";
    person.AppendChild(newElement);
    xml.Save(Server.MapPath("~/test.xml"));
    也可以参考:在.NET中使用XML、读取XML文件,插入数据到XML文 
      

  3.   


    操作XMl或者百度。。xmlhelper...
      

  4.   

    插入XML
    public static 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 { }
            }
      

  5.   

     XmlDocument document = new XmlDocument();
               string text = null;
               text += "<outer_id action="delete">"+ 你的值 +"</outer_id>";
               text = text.Replace("&", "&amp;");
               document.LoadXml(@"<外层>" + text + "</外层>");
               string path = "test.xml";
               document.Save(HttpContext.Current.Server.MapPath(path));
               ds.Dispose();