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


C# XmlDocument.CreateXmlDeclaration方法代码示例

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


在下文中一共展示了XmlDocument.CreateXmlDeclaration方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: InvalidStandalone2

        public static void InvalidStandalone2()
        {
            var xmlDocument = new XmlDocument();

            var decl = xmlDocument.CreateXmlDeclaration("1.0", null, "yes");

            Assert.Equal(decl.Encoding, String.Empty);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:CreateXmlDeclarationTests.cs

示例8: CheckAllAttributes

        public static void CheckAllAttributes()
        {
            var xmlDocument = new XmlDocument();

            var decl = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            Assert.Equal("1.0", decl.Version);
            Assert.Equal("UTF-8", decl.Encoding);
            Assert.Equal("yes", decl.Standalone);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:CreateXmlDeclarationTests.cs

示例9: CheckAllAttributesOnCloneFalse

        public static void CheckAllAttributesOnCloneFalse()
        {
            var xmlDocument = new XmlDocument();

            var decl = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            var declCloned = (XmlDeclaration)decl.CloneNode(false);

            Assert.Equal("1.0", declCloned.Version);
            Assert.Equal("UTF-8", declCloned.Encoding);
            Assert.Equal("yes", declCloned.Standalone);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:CreateXmlDeclarationTests.cs

示例10: 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

示例11: SaveToXML

    public static void SaveToXML(IntFontInfo fnt, string outPath)
    {
        XmlDocument doc = new XmlDocument();
        XmlDeclaration decl = doc.CreateXmlDeclaration("1.0","utf-8",null);
        XmlElement root = doc.CreateElement("font");
        doc.InsertBefore(decl, doc.DocumentElement);
        doc.AppendChild(root);

        XmlElement common = doc.CreateElement("common");
        common.SetAttribute("lineHeight", fnt.lineHeight.ToString());
        common.SetAttribute("scaleW", fnt.scaleW.ToString());
        common.SetAttribute("scaleH", fnt.scaleH.ToString());
        common.SetAttribute("pages", "1");
        root.AppendChild(common);

        XmlElement pages = doc.CreateElement("pages");
        XmlElement page1 = doc.CreateElement("page");
        page1.SetAttribute("id", "0");
        page1.SetAttribute("file", fnt.texName);
        pages.AppendChild(page1);
        root.AppendChild(pages);

        XmlElement chars = doc.CreateElement("chars");
        chars.SetAttribute("count", fnt.chars.Count.ToString());
        foreach(IntChar c in fnt.chars){
            XmlElement cNode = doc.CreateElement("char");
            cNode.SetAttribute("id", c.id.ToString());
            cNode.SetAttribute("x", c.x.ToString());
            cNode.SetAttribute("y", c.y.ToString());
            cNode.SetAttribute("width", c.width.ToString());
            cNode.SetAttribute("height", c.height.ToString());
            cNode.SetAttribute("xoffset", c.xoffset.ToString());
            cNode.SetAttribute("yoffset", c.yoffset.ToString());
            cNode.SetAttribute("xadvance", c.xadvance.ToString());
            chars.AppendChild(cNode);
        }
        root.AppendChild(chars);

        XmlElement kernings = doc.CreateElement("kernings");
        kernings.SetAttribute("count", fnt.kernings.Count.ToString());
        foreach(IntKerning k in fnt.kernings){
            XmlElement kNode = doc.CreateElement("kerning");
            kNode.SetAttribute("first", k.first.ToString());
            kNode.SetAttribute("second", k.second.ToString());
            kNode.SetAttribute("amount", k.amount.ToString());
            kernings.AppendChild(kNode);
        }
        root.AppendChild(kernings);
        doc.Save(outPath);
    }
开发者ID:groscalin,项目名称:unityScriptLab,代码行数:50,代码来源:BMFont.cs

示例12: 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

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string sSiteMapFilePath = HttpRuntime.AppDomainAppPath + "sitemap.xml";
        var fi = new FileInfo(sSiteMapFilePath);

        //if (fi.Exists && fi.LastWriteTime < DateTime.Now.AddHours(-1))
        //{ // only allow it to be written once an hour in case someone spams this page (so it doesnt crash the site)

        _xd = new XmlDocument();
        XmlNode rootNode = _xd.CreateElement("urlset");

        // add namespace
        var attrXmlNS = _xd.CreateAttribute("xmlns");
        attrXmlNS.InnerText = "http://www.sitemaps.org/schemas/sitemap/0.9";
        rootNode.Attributes.Append(attrXmlNS);

        //add img namespace
        var attrXmlNS2 = _xd.CreateAttribute("xmlns:image");
        attrXmlNS2.InnerText = "http://www.google.com/schemas/sitemap-image/1.1";
        rootNode.Attributes.Append(attrXmlNS2);

        // home page
        rootNode.AppendChild(GenerateUrlNode("http://www.how-to-asp.net", DateTime.Now, "hourly", "1.00", "http://myimage.com"));

        // ADD THE REST OF YOUR URL'S HERE

        // append all nodes to the xmldocument and save it to sitemap.xml
        _xd.AppendChild(rootNode);
        _xd.InsertBefore(_xd.CreateXmlDeclaration("1.0", "UTF-8", null), rootNode);
        _xd.Save(sSiteMapFilePath);

        // PING SEARCH ENGINES TO LET THEM KNOW YOU UPDATED YOUR SITEMAP
        // resubmit to google
        //System.Net.WebRequest reqGoogle = System.Net.WebRequest.Create("http://www.google.com/webmasters/tools/ping?sitemap=" + HttpUtility.UrlEncode("http://www.how-to-asp.net/sitemap.xml"));
        //reqGoogle.GetResponse();

        //// resubmit to ask
        //System.Net.WebRequest reqAsk = System.Net.WebRequest.Create("http://submissions.ask.com/ping?sitemap=" + HttpUtility.UrlEncode("http://www.how-to-asp.net/sitemap.xml"));
        //reqAsk.GetResponse();

        //// resubmit to yahoo
        //System.Net.WebRequest reqYahoo = System.Net.WebRequest.Create("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" + HttpUtility.UrlEncode("http://www.how-to-asp.net/sitemap.xml"));
        //reqYahoo.GetResponse();

        //// resubmit to bing
        //System.Net.WebRequest reqBing = System.Net.WebRequest.Create("http://www.bing.com/webmaster/ping.aspx?siteMap=" + HttpUtility.UrlEncode("http://www.how-to-asp.net/sitemap.xml"));
        //reqBing.GetResponse();
    }
开发者ID:haithemaraissia,项目名称:Advertise,代码行数:48,代码来源:SiteMapXMLSEO.aspx.cs

示例14: CreateXmlFile

 public static void CreateXmlFile(string path, string rootName)
 {
     try
     {
         XmlDocument doc = new XmlDocument();
         //建立Xml的定义声明
         XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
         doc.AppendChild(dec);
         //创建根节点
         XmlElement root = doc.CreateElement(rootName);
         doc.AppendChild(root);
         doc.Save(path);
     }
     catch
     {
     }
 }
开发者ID:hj-nicholas,项目名称:BaseFrame,代码行数:17,代码来源:XmlHelper.cs

示例15: CreateXmlFile

    /// <summary>
    /// xml�t�@�C���������\�b�h
    /// <para>�@�擾����xml�����݂��Ȃ��ꍇ�ɐ�����s�����\�b�h�B</para>
    /// </summary>
    public void CreateXmlFile()
    {
        // xml�C���X�^���g��쐬
        XmlDocument document = new XmlDocument();
        XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", "UTF-8", null);
        XmlElement root = document.CreateElement("UBTProject");  // ���[�g�v�f
        document.AppendChild(declaration);                       // �w�肵���m�[�h��q�m�[�h�Ƃ��Ēlj�
        document.AppendChild(root);

        // ���[�U�[���̗v�f��쐬
        XmlElement elementUserPrm = document.CreateElement("UserParams");
        root.AppendChild(elementUserPrm);
        XmlElement userName = document.CreateElement("UserName");
        userName.InnerText = "NONE";
        elementUserPrm.AppendChild(userName);
        XmlElement guID = document.CreateElement("Guid");
        guID.InnerText = "NONE";
        elementUserPrm.AppendChild(guID);

        // ���j�b�g���X�g�̗v�f��쐬
        for (int i = 0; 16 > i; i++)
        {
            XmlElement elementUnitSts0 = document.CreateElement("UnitStatus_" + i.ToString());
            root.AppendChild(elementUnitSts0);
            XmlElement UnitID_0 = document.CreateElement("UnitID");
            UnitID_0.InnerText = "99";
            elementUnitSts0.AppendChild(UnitID_0);
            XmlElement UnitClass_0 = document.CreateElement("UnitClass");
            UnitClass_0.InnerText = "99";
            elementUnitSts0.AppendChild(UnitClass_0);
            XmlElement UnitName_0 = document.CreateElement("UnitName");
            UnitName_0.InnerText = "NONE";
            elementUnitSts0.AppendChild(UnitName_0);
            XmlElement UnitAbility1_0 = document.CreateElement("UnitAbility1");
            UnitAbility1_0.InnerText = "99";
            elementUnitSts0.AppendChild(UnitAbility1_0);
            XmlElement UnitAbility2_0 = document.CreateElement("UnitAbility2");
            UnitAbility2_0.InnerText = "99";
            elementUnitSts0.AppendChild(UnitAbility2_0);
            XmlElement UnitElement_0 = document.CreateElement("UnitElement");
            UnitElement_0.InnerText = "99";
            elementUnitSts0.AppendChild(UnitElement_0);
        }
        // �t�@�C���֕ۑ�����
        document.Save("var.xml");
    }
开发者ID:yagamiiori,项目名称:Eda,代码行数:50,代码来源:bak2_AppSettings.cs


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