Beispiel #1
0
 ///// <summary>
 ///// 添加属性
 ///// </summary>
 ///// <param name="arr">
 ///// 第一个参数:xml实例化类\n
 ///// 第二个参数:属性名称\n
 ///// 第三个参数:属性值
 ///// </param>
 ///// <returns></returns>
 //public static XmlAttribute AddAttibute(this XmlNode _xmlElement, params object[] arr)
 //{
 //    XMLCreater u_Xml = (XMLCreater)arr[0];
 //    XmlAttribute xmlAttribute = u_Xml.XmlDoc.CreateAttribute((string)(arr[1]));
 //    xmlAttribute.Value = (string)arr[2];
 //    _xmlElement.Attributes.Append(xmlAttribute);
 //    return xmlAttribute;
 //}
 /// <summary>
 /// 
 ///添加属性 
 /// </summary>
 /// <param name="_xmlElement"></param>
 /// <param name="self"></param>
 /// <param name="attributeName"></param>
 /// <param name="attrbuteVal"></param>
 /// <returns></returns>
 public static XmlAttribute AddAttibute(this XmlNode _xmlElement, XMLCreater self, string attributeName, string attrbuteVal)
 {
     XMLCreater u_Xml = self;
     XmlAttribute xmlAttribute = u_Xml.XmlDoc.CreateAttribute(attributeName);
     xmlAttribute.Value = attrbuteVal;
     _xmlElement.Attributes.Append(xmlAttribute);
     return xmlAttribute;
 }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            XMLCreater create = new XMLCreater("c:\\xml.xml", "root");

            XmlNode node1 = create.RootElement.AddNode(create, "users");
            node1.AddAttibute(create, "target", "orgval");
            XmlNode n = node1.AddNode(create, "user").AddAttibute(create, "asd", "as");

            create.Save();
        }
Beispiel #3
0
 ///// <summary>
 ///// 添加节点
 ///// </summary>
 ///// <param name="arr">
 ///// 第一个参数:xml实例化类\n
 ///// 第二个参数:节点名字
 ///// </param>
 ///// <returns></returns>
 //public static XmlNode AddNode(this XmlNode _xmlElement, params object[] arr)
 //{
 //    XMLCreater u_Xml = (XMLCreater)arr[0];
 //    XmlNode xmlNode = u_Xml.XmlDoc.CreateNode(XmlNodeType.Element, (string)arr[1], "");
 //    _xmlElement.AppendChild(xmlNode);//添加节点
 //    return xmlNode;
 //}
 public static XmlNode AddNode(this XmlNode _xmlElement, XMLCreater self, string nodeName)
 {
     XMLCreater u_Xml = self;
     XmlNode xmlNode = u_Xml.XmlDoc.CreateNode(XmlNodeType.Element, nodeName, "");
     _xmlElement.AppendChild(xmlNode);//添加节点
     return xmlNode;
 }