当前位置: 首页>>代码示例>>C#>>正文


C# XmlDocument.AppendChild方法代码示例

本文整理汇总了C#中XmlDocument.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.AppendChild方法的具体用法?C# XmlDocument.AppendChild怎么用?C# XmlDocument.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlDocument的用法示例。


在下文中一共展示了XmlDocument.AppendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: get_frm_xml_with_value

 public string get_frm_xml_with_value()
 {
     XmlDocument doc = new XmlDocument();
     XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
     doc.AppendChild(dec);
     XmlElement root = doc.CreateElement("AddressInformation");
     doc.AppendChild(dec);
     xmlElement(doc, root, "txt_oh_city_city", txt_oh_city_city.Text);
     xmlElement(doc, root, "txt_oh_exp", txt_oh_exp.Text);
     xmlElement(doc, root, "txt_oh_fax", txt_oh_fax.Text);
     xmlElement(doc, root, "txt_oh_floor", txt_oh_floor.Text);
     xmlElement(doc, root, "txt_oh_mob", txt_oh_mob.Text);
     xmlElement(doc, root, "txt_oh_pelak", txt_oh_pelak.Text);
     xmlElement(doc, root, "txt_oh_postal_code", txt_oh_postal_code.Text);
     xmlElement(doc, root, "txt_oh_street_main1", txt_oh_street_main1.Text);
     xmlElement(doc, root, "txt_oh_street_main2", txt_oh_street_main2.Text);
     xmlElement(doc, root, "txt_oh_street_other1", txt_oh_street_other1.Text);
     xmlElement(doc, root, "txt_oh_street_other2", txt_oh_street_other2.Text);
     xmlElement(doc, root, "txt_oh_tel", txt_oh_tel.Text);
     xmlElement(doc, root, "txt_oh_tel_nec", txt_oh_tel_nec.Text);
     xmlElement(doc, root, "txt_oh_unit", txt_oh_unit.Text);
     xmlElement(doc, root, "drp_oh_link_to_city", drp_oh_link_to_city.SelectedValue.ToString());
     xmlElement(doc, root, "drp_oh_link_to_country", drp_oh_link_to_country.SelectedValue.ToString());
     doc.AppendChild(root);
     return doc.InnerXml;
 }
开发者ID:bahmany,项目名称:barIran,代码行数:26,代码来源:pnl_address_information_form.ascx.cs

示例2: SaveStatistik

    public void SaveStatistik(string statText, string name)
    {
        CheckFile ();
        // Создаем корневой элемент
        XmlDocument xmlDoc = new XmlDocument ();
        if(File.Exists(filePatch))
            xmlDoc.Load (filePatch);

        XmlNode xRoot;
        XmlNode findNode = xmlDoc.SelectSingleNode ("Stats"); // найти корневой элемент
        if ( findNode == null)
            xRoot = xmlDoc.CreateElement ("Stats"); 	// Создать корневой элемент
        else
            xRoot = findNode;

        xmlDoc.AppendChild (xRoot);

        //Временные преременные для дочерних элементов и атрибутов
        XmlElement taskElement1; //Элемент 1-го уровня

        findNode = xmlDoc.SelectSingleNode ("Stats/" + name);
        if ( findNode == null) {
            taskElement1 = xmlDoc.CreateElement (name);
            taskElement1.InnerText = statText;
            xRoot.AppendChild (taskElement1);
        } else {
            findNode.InnerText = statText;
        }

        /////////////////////////////////////////////////////////////
        xmlDoc.Save ("Data/Save/Stats.xml");
    }
开发者ID:Antis28,项目名称:JuperFly,代码行数:32,代码来源:SaveStats.cs

示例3: Post

    public string Post(string title, string description, string exp, string match, string unmatch, string author)
    {
        XmlDocument doc = new XmlDocument(); ;
        string xmlfile = Server.MapPath("/Data/useful.xml");
        if (!File.Exists(xmlfile))
        {
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            doc.AppendChild(doc.CreateElement("regs"));
        }
        else
        {
            doc.Load(xmlfile);
        }
        XmlElement e = doc.CreateElement("reg");
        e.Attributes.Append(doc.CreateAttribute("title")).Value = title;
        e.Attributes.Append(doc.CreateAttribute("description")).Value = description;
        e.Attributes.Append(doc.CreateAttribute("match")).Value = match;
        e.Attributes.Append(doc.CreateAttribute("unmatch")).Value = unmatch;
        e.Attributes.Append(doc.CreateAttribute("author")).Value = author;
        e.Attributes.Append(doc.CreateAttribute("date")).Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        e.Attributes.Append(doc.CreateAttribute("exp")).Value = exp;

        if (doc.DocumentElement.ChildNodes.Count > 0)
            doc.DocumentElement.InsertBefore(e, doc.DocumentElement.ChildNodes[0]);
        else
            doc.DocumentElement.AppendChild(e);

        doc.Save(xmlfile);

        return "0";
    }
开发者ID:kingshang,项目名称:regex,代码行数:31,代码来源:AddExpression.aspx.cs

示例4: get_frm_xml_with_value

    public string get_frm_xml_with_value()
    {
        XmlDocument doc = new XmlDocument();

        XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
        doc.AppendChild(dec);
        XmlElement root = doc.CreateElement("PersonalInformation");
        doc.AppendChild(dec);
        xmlElement(doc, root, "txt_birth_place", txt_birth_place.Text);
        xmlElement(doc, root, "txt_birthDate", txt_birthDate.Text);
        xmlElement(doc, root, "txt_family", txt_family.Text);
        xmlElement(doc, root, "txt_fathername", txt_fathername.Text);
        xmlElement(doc, root, "txt_insurance_Code", txt_insurance_Code.Text);
        xmlElement(doc, root, "txt_international_code", txt_international_code.Text);
        xmlElement(doc, root, "txt_name", txt_name.Text);
        xmlElement(doc, root, "txt_oh_education_branch", txt_oh_education_branch.Text);
        xmlElement(doc, root, "txt_oh_serial_1", "1");
        xmlElement(doc, root, "txt_oh_serial_3", "1");
        xmlElement(doc, root, "txt_registration_place", txt_registration_place.Text);
        xmlElement(doc, root, "txt_shsh", txt_shsh.Text);
        xmlElement(doc, root, "drp_oh_link_to_education", drp_oh_link_to_education.SelectedValue.ToString());
        xmlElement(doc, root, "drp_oh_sex", drp_oh_sex.SelectedValue.ToString());
        xmlElement(doc, root, "drp_txt_oh_serial_2", "1");
        xmlElement(doc, root, "img_pic_person", img_pic_person.ImageUrl);

        doc.AppendChild(root);
        return doc.InnerXml;
    }
开发者ID:bahmany,项目名称:barIran,代码行数:28,代码来源:pnl_personal_information_form.ascx.cs

示例5: Config

 /// <summary>
 /// Creates a new instance of config provider
 /// </summary>
 /// <param name="configType">Config type</param>
 protected Config(Type configType)
 {
     if (configType == null)
     {
         throw new ArgumentNullException("configType");
     }
     _document = new XmlDocument();
     if (File.Exists(ConfigFile))
     {
         _document.Load(ConfigFile);
     }
     else
     {
         var declaration = _document.CreateXmlDeclaration("1.0", "UTF-8", null);
         _document.AppendChild(declaration);
         var documentNode = _document.CreateElement(CONFIG_NODE);
         _document.AppendChild(documentNode);
     }
     _typeNode = _document.DocumentElement.SelectSingleNode(configType.Name);
     if (_typeNode == null)
     {
         _typeNode = _document.CreateElement(configType.Name);
         _document.DocumentElement.AppendChild(_typeNode);
     }
 }
开发者ID:san90279,项目名称:UK_OAS,代码行数:29,代码来源:Config.cs

示例6: CreateXML

 //创建XML文件
 public bool CreateXML(string FileName)
 {
     if (isXMLExict(FileName))
         return false;
     XmlDocument xmlDoc = new XmlDocument();
     //添加XML第一行格式
     XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
     xmlDoc.AppendChild(xmlDec);
     //添加根节点,以文件名作为根节点名
     XmlElement xmlelem = xmlDoc.CreateElement(FileName);
     xmlDoc.AppendChild(xmlelem);
     xmlDoc.Save(GetPathWithFileName(FileName));
     return true;
 }
开发者ID:huanzheWu,项目名称:Purity-Cat-_Unity3D-Game,代码行数:15,代码来源:XMLManager.cs

示例7: Post

    public string Post(string name, string email, string content)
    {
        if (name.Length > 32)
        {
            return "1";
        }
        if (!Regex.IsMatch(email, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
        {
            return "2";
        }

        if (email.Length > 128)
        {
            return "2";
        }
        if (content.Length > 3000)
        {
            return "3";
        }

        string ip = HttpContext.Current.Request.UserHostAddress;
        //Database db = DatabaseFactory.CreateDatabase();
        //using (DbCommand cmd = db.GetStoredProcCommand("Suggests_Insert", new object[] { name, email, content, ip }))
        //{
        //    db.ExecuteNonQuery(cmd);
        //    return cmd.Parameters["@RETURN_VALUE"].Value.ToString();
        //}

        XmlDocument doc = new XmlDocument(); ;
        string xmlfile = Server.MapPath("/Data/offer.xml");
        if (!File.Exists(xmlfile))
        {
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            doc.AppendChild(doc.CreateElement("suggests"));
        }
        else
        {
            doc.Load(xmlfile);
        }
        XmlElement e = doc.CreateElement("suggest");
        e.Attributes.Append(doc.CreateAttribute("name")).Value = name;
        e.Attributes.Append(doc.CreateAttribute("email")).Value = email;
        e.Attributes.Append(doc.CreateAttribute("content")).Value = content;
        e.Attributes.Append(doc.CreateAttribute("ip")).Value = ip;
        doc.DocumentElement.AppendChild(e);
        doc.Save(xmlfile);

        return "0";
    }
开发者ID:kingshang,项目名称:regex,代码行数:49,代码来源:Offer.aspx.cs

示例8: GetPlayerChartXML

    protected string GetPlayerChartXML()
    {
        XmlDocument xmlDoc = new XmlDocument();
        XmlNode xmlNode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
        xmlDoc.AppendChild(xmlNode);
        XmlElement xEle = xmlDoc.CreateElement("graph");
        xEle.SetAttribute("showvalues", "0");
        XmlElement categories = xmlDoc.CreateElement("categories");
        XmlElement pointsPerGame = xmlDoc.CreateElement("dataset");
        pointsPerGame.SetAttribute("seriesname", "Points per Game");
        pointsPerGame.SetAttribute("color", "#000000");
        XmlElement assistsPerGame = xmlDoc.CreateElement("dataset");
        assistsPerGame.SetAttribute("seriesname", "Assists per Game");
        assistsPerGame.SetAttribute("color", "#000066");
        XmlElement goalsPerGame = xmlDoc.CreateElement("dataset");
        goalsPerGame.SetAttribute("seriesname", "Goals per Game");
        goalsPerGame.SetAttribute("color", "#660000");
        XmlElement tmpElement;
        String sqlString = GetDataString();
        SqlCommand sqlCommand = new SqlCommand(sqlString, scripts.GetConnection());
        using (SqlDataReader reader = sqlCommand.ExecuteReader())
        {
            while (reader.Read())
            {
                tmpElement = xmlDoc.CreateElement("category");
                tmpElement.SetAttribute("name", Convert.ToString(reader[3]));
                categories.AppendChild(tmpElement);

                tmpElement = xmlDoc.CreateElement("set");
                tmpElement.SetAttribute("value", Convert.ToString(reader[2]));
                pointsPerGame.AppendChild(tmpElement);

                tmpElement = xmlDoc.CreateElement("set");
                tmpElement.SetAttribute("value", Convert.ToString(reader[1]));
                goalsPerGame.AppendChild(tmpElement);

                tmpElement = xmlDoc.CreateElement("set");
                tmpElement.SetAttribute("value", Convert.ToString(reader[0]));
                assistsPerGame.AppendChild(tmpElement);
            }
        }
        xEle.AppendChild(categories);
        xEle.AppendChild(pointsPerGame);
        xEle.AppendChild(assistsPerGame);
        xEle.AppendChild(goalsPerGame);
        xmlDoc.AppendChild(xEle);
        return xmlDoc.OuterXml;
    }
开发者ID:Aphramzo,项目名称:AnAvalancheOfStats,代码行数:48,代码来源:PlayerChart.aspx.cs

示例9: GetCustomerInfo

    public XmlDocument GetCustomerInfo()
    {
        XmlUtil x_util = new XmlUtil();
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        XmlNode status = null;
        XmlDocument Response = new XmlDocument();
        XmlNode root = Response.CreateElement("response");
        Response.AppendChild(root);
        try
        {
            DB db = new DB();
            String sql = "SELECT COUNT(*) FROM customers WHERE status!='inactive'";
            String count = db.ViziAppsExecuteScalar(State, sql);
            x_util.CreateNode(Response, root, "customer_count", count);
            db.CloseViziAppsDatabase(State);
            x_util.CreateNode(Response, root, "status", "success");
        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);

            if (status == null)
            {
                Response = new XmlDocument();
                XmlNode root2 = Response.CreateElement("response");
                Response.AppendChild(root2);
                status = x_util.CreateNode(Response, root2, "status");

            }
            status.InnerText = SE.Message;
            util.LogError(State, SE);
        }
        return Response;
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:35,代码来源:PhoneWebService.cs

示例10: OpenAppXMLFile

    public XmlDocument OpenAppXMLFile()
    {
        string App_Path = @ConfigurationManager.AppSettings["Data_Path"].ToString();
        App_Path = App_Path + "Items.xml";

        if (File.Exists(@App_Path))
        {
            try
            {
                xmldoc = new XmlDocument();
                xmldoc.Load(@App_Path);
            }
            catch (Exception ex)
            {
                ///  Do not currently understand how to terminate the ThreadStart in the event of a failure
                GlobalClass.ErrorMessage = "Error in AppThreads(OpenAppFile): " + ex.Message;

            }

        }
        else
        {
            xmldoc = new XmlDocument();
            XmlNode iheader = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null);
            xmldoc.AppendChild(iheader);
            XmlElement root = xmldoc.CreateElement("dataroot");
            xmldoc.InsertAfter(root, iheader);
            xmldoc.Save(@App_Path);

        }

         return  xmldoc;
    }
开发者ID:emcgurty,项目名称:ASP_NET_with_XML_List,代码行数:33,代码来源:GetXMLdoc.cs

示例11: GetXml

    /// <summary>
    /// To Create Xml file for every multiselect list to pass data of xml type in database
    /// </summary>
    /// <param name="DtXml"></param>
    /// <param name="Text"></param>
    /// <param name="Value"></param>
    /// <param name="XmlFileName"></param>
    /// <returns></returns>
    public string GetXml(DataTable DtXml, String Text, String Value,string XmlFileName)
    {
        XmlDocument xmldoc = new XmlDocument();
        //To create Xml declarartion in xml file
        XmlDeclaration decl = xmldoc.CreateXmlDeclaration("1.0", "UTF-16", "");
        xmldoc.InsertBefore(decl, xmldoc.DocumentElement);
        XmlElement RootNode = xmldoc.CreateElement("Root");
        xmldoc.AppendChild(RootNode);
        for (int i = 0; i < DtXml.Rows.Count; i++)
        {
            XmlElement childNode = xmldoc.CreateElement("Row");
            childNode.SetAttribute(Value, DtXml.Rows[i][1].ToString());
            childNode.SetAttribute(Text, DtXml.Rows[i][0].ToString());
            RootNode.AppendChild(childNode);
        }

        //Check if directory already exist or not otherwise
        //create directory
        if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("XML")))
            Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("XML"));
        XmlFileName = "XML" + "\\" + XmlFileName;

        //To save xml file on respective path
        xmldoc.Save(System.Web.HttpContext.Current.Server.MapPath(XmlFileName));
        xmldoc.RemoveChild(xmldoc.FirstChild);
        string RetXml = xmldoc.InnerXml;
        return RetXml;
    }
开发者ID:kamleshdaxini,项目名称:LocalDevelopment,代码行数:36,代码来源:DynamicXml.cs

示例12: Log

    private static void Log(string pInfoType, string pFilepath, string pContent, string pDetail, string pRootName)
    {
        if (!AllowLog) return;

        try
        {
            XmlDocument docXml = new XmlDocument();
            try{
                docXml.Load(pFilepath);
            }
            catch (Exception ex){
                docXml = new XmlDocument();
            }

            XmlElement Goc = docXml.DocumentElement;
            if ((Goc == null))
            {
                Goc = docXml.CreateElement(pRootName);
                docXml.AppendChild(Goc);
            }

            XmlElement The = docXml.CreateElement(pInfoType);
            The.SetAttribute("At", DateTime.Now.ToString("dd\\/MM\\/yyyy HH:mm:ss"));
            The.SetAttribute("Message", pContent);
            The.SetAttribute("Detail", pDetail);

            Goc.AppendChild(The);
            docXml.Save(pFilepath);
        }
        catch (Exception ex)
        {
        }
    }
开发者ID:dexonhud,项目名称:pharmacykimhoang,代码行数:33,代码来源:TLog.cs

示例13: GenerateXml

	public static void GenerateXml()
	{
		Debug.Log("Processing..");
		enXml = new XmlDocument();
		ruXml = new XmlDocument();

		XmlUtil.xmlId = 0;

		string enXmlPath = String.Format(@"{0}\{1}", Application.dataPath, "data_en.xml");
		string ruXmlPath = String.Format(@"{0}\{1}", Application.dataPath, "data_ru.xml");

		if(File.Exists(enXmlPath))
		{
			enXml.Load(enXmlPath);
			ruXml.Load(ruXmlPath);

			XmlUtil.ruRootNode = (XmlElement)ruXml.FirstChild;
			XmlUtil.enRootNode = (XmlElement)enXml.FirstChild;
		}
		else
		{
			XmlUtil.enRootNode = (XmlElement)enXml.AppendChild(enXml.CreateElement("document"));
			XmlUtil.ruRootNode = (XmlElement)ruXml.AppendChild(ruXml.CreateElement("document"));
		}
		string startSearchPath = Application.dataPath;
		XmlUtil.GetAssets(startSearchPath); ///--- путь к ассетам
		XmlUtil.enXml.Save("data_en.xml");
		XmlUtil.ruXml.Save("data_ru.xml");
	}
开发者ID:vlad123kuznetsov,项目名称:Locator,代码行数:29,代码来源:XmlUtil.cs

示例14: saveXML

    public void saveXML(string path)
    {
        XmlDocument doc = new XmlDocument ();
        XmlElement main = doc.CreateElement ("Config");
        XmlAttribute version = doc.CreateAttribute ("Version");
        version.Value = configVersion;
        main.Attributes.Append (version);
        XmlAttribute lastMap = doc.CreateAttribute ("lastCompletedMap");
        lastMap.Value = lastCompletedLevel;
        main.Attributes.Append (lastMap);
        XmlNode score = doc.CreateNode (XmlNodeType.Element, "ScoreHistory", "");
        foreach(int i in scoreHistory ){
            XmlElement node = doc.CreateElement("Score");
            XmlAttribute val = doc.CreateAttribute("Value");
            val.Value = i.ToString();
            node.Attributes.Append(val);
            score.AppendChild(node);
        }

        main.AppendChild (score);
        doc.AppendChild (main);
        doc.Save(path);
        /*
        //doc.l
        using (var stream = new FileStream(path, FileMode.Create)) {
            using (StreamWriter writer = new StreamWriter(stream))
                writer.Write (data);
        }
        */
    }
开发者ID:allfa,项目名称:Reborn,代码行数:30,代码来源:config.cs

示例15: createXml

    public void createXml()
    {
        string filepath = Application.dataPath + @"/my.xml";
        if(!File.Exists (filepath))
        {
             XmlDocument xmlDoc = new XmlDocument();
             XmlElement root = xmlDoc.CreateElement("transforms");
             XmlElement elmNew = xmlDoc.CreateElement("rotation");
             elmNew.SetAttribute("id","0");
         		     elmNew.SetAttribute("name","momo");

             XmlElement rotation_X = xmlDoc.CreateElement("x");
             rotation_X.InnerText = "0";
             XmlElement rotation_Y = xmlDoc.CreateElement("y");
             rotation_Y.InnerText = "1";
             XmlElement rotation_Z = xmlDoc.CreateElement("z");
             rotation_Z.InnerText = "2";
           			 rotation_Z.SetAttribute("id","1");

             elmNew.AppendChild(rotation_X);
             elmNew.AppendChild(rotation_Y);
             elmNew.AppendChild(rotation_Z);
             root.AppendChild(elmNew);
             xmlDoc.AppendChild(root);
             xmlDoc.Save(filepath);
             Debug.Log("createXml OK!");
        }
    }
开发者ID:CzDreamer,项目名称:QFramework,代码行数:28,代码来源:Test.cs


注:本文中的XmlDocument.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。