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


C# XmlTextWriter.WriteEndDocument方法代码示例

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


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

示例1: Main

    static void Main()
    {
        using (var reader = new StreamReader(inputFile))
        {
            string line = reader.ReadLine();

            if (line == null)
            {
                Console.WriteLine("The text file is empty");
                return;
            }

            using (var writer = new XmlTextWriter(outputFile, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();
                writer.WriteStartElement("People");

                while (line != null)
                {
                    var tokens = line.Split(';').Select(t => t.Trim()).ToArray();

                    WritePerson(writer, name: tokens[0], address: tokens[1], phone: tokens[2]);
                    line = reader.ReadLine();
                }

                writer.WriteEndDocument();

                Console.WriteLine("XML file saved to {0}", outputFile);
            }
        }
    }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:35,代码来源:TextToXml.cs

示例2: BuildXMLString

    private string BuildXMLString()
    {
        StringWriter str = new StringWriter();
        XmlTextWriter xml = new XmlTextWriter(str);

        // start doc and root el.
        xml.WriteStartDocument();
        xml.WriteStartElement("playerScoreList");

        // data element
        xml.WriteStartElement("player");
        xml.WriteElementString("name", "matt");
        xml.WriteElementString("score", "200");
        xml.WriteEndElement();

        // data element
        xml.WriteStartElement("player");
        xml.WriteElementString("name", "jane");
        xml.WriteElementString("score", "150");
        xml.WriteEndElement();

        // end root and document
        xml.WriteEndElement();
        xml.WriteEndDocument();

        return str.ToString();
    }
开发者ID:kdoore,项目名称:unity-5-cookbook-codes,代码行数:27,代码来源:CreateXMLString.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("urlset");
        writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

        string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
        if (!Request.Url.IsDefaultPort)
        {
            siteUrl += ":" + Request.Url.Port;
        }
        Menu menu = new Menu();
        Utils.InitMenu(menu, false, false, false);
        foreach (MenuItem item in menu.Items)
        {
            writer.WriteStartElement("url");
            writer.WriteElementString("loc", siteUrl + item.NavigateUrl);
            writer.WriteEndElement();
            foreach (MenuItem childItem in item.ChildItems)
            {
                writer.WriteStartElement("url");
                writer.WriteElementString("loc", siteUrl + childItem.NavigateUrl);
                writer.WriteEndElement();
            }
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        Response.End();
    }
开发者ID:ivladyka,项目名称:Ekran,代码行数:33,代码来源:SiteMap.aspx.cs

示例4: Main

    static void Main()
    {
        using (var writer = new XmlTextWriter(filePath, encoding))
        {
            writer.Formatting = Formatting.Indented;
            writer.IndentChar = '\t';
            writer.Indentation = 1;

            writer.WriteStartDocument();
            writer.WriteStartElement("catalogue");
            writer.WriteAttributeString("name", "Awesome Mix Vol. 1");

            WriteAlbum(writer, "Hooked on a Feeling", "Blue Swede", 1968, "Scepter Records", 20);

            WriteAlbum(writer, "Record World", "Raspberries", 1972, "Capitol Records", 18.50m,
                new List<string>() { "Don't Want to Say Goodbye", "Go All the Way", "I Wanna Be with You" });

            WriteAlbum(writer, "Starting Over", "Raspberries", 1974, "Capitol", 17.50m);

            WriteAlbum(writer, "Wovoka", "Redbone", 1974, "Lolly Vegas", 11,
                new List<string>() { "Come and Get Your Love", "When You Got Trouble" });

            WriteAlbum(writer, "The 5th Dimension", "Blue Swede", 1974, "Warner Bros.", 9.99m);

            writer.WriteEndDocument();
        }

        Console.WriteLine("Document saved to {0}", filePath);
    }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:29,代码来源:CreateXMLFile.cs

示例5: Main

    static void Main()
    {
        XmlReader reader = XmlReader.Create("../../catalogue.xml");
        using (reader)
        {
            StreamWriter textWriter = new StreamWriter("../../albums.xml", false, Encoding.GetEncoding("utf-8"));
            XmlTextWriter writer = new XmlTextWriter(textWriter);
            using (writer)
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("album-catalog");
                while (reader.Read())
                {
                    if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "album"))
                    {
                        writer.WriteStartElement("album");
                        reader.ReadToDescendant("name");
                        writer.WriteElementString(reader.Name, reader.ReadInnerXml());
                        reader.ReadToNextSibling("artist");
                        writer.WriteElementString(reader.Name, reader.ReadInnerXml());
                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
    }
开发者ID:vasilkrvasilev,项目名称:Databases,代码行数:29,代码来源:ReadWrite.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        objX.WriteStartDocument();
        objX.WriteStartElement("rss");
        objX.WriteAttributeString("version", "2.0");
        objX.WriteStartElement("channel");
        objX.WriteElementString("title", drvvv.Plugins.GetTextToSite("Anglodeals", "francodeals", "zebradeals"));
        objX.WriteElementString("link", "http://anglodeals.co.il/rss.aspx");
        objX.WriteElementString("description", "At  Deals we compile the best coupons from both English and Hebrew anf franch websites daily, translate what is needed and put them up on one user-friendly website.");
        objX.WriteElementString("copyright", "(c) 2012, anglodeals. All rights reserved.");
        //objX.WriteElementString("ttl", "5");

        foreach (var x in drvvv.drvvvSettings.GetDataContextInstance().Coupons.Where(x => x.Active && x.EndDate >= DateTime.Now && x.TitleEn != null).OrderByDescending(x => x.ID).Take(30))
        {
            objX.WriteStartElement("item");
            objX.WriteElementString("guid", x.ID.ToString());
            objX.WriteElementString("title", drvvv.Plugins.GetTextToSite(x.TitleEn, x.TitleFr, x.TitleDefault));
            objX.WriteElementString("image", (drvvv.Plugins.ReturnImgAddress(x.ImgName)).Replace("~/", drvvv.Plugins.GetTextToSite("http://anglodeals.co.il/", "http://francodeals.co.il/", "http://zebradeals.co.il/")));
            objX.WriteElementString("description", drvvv.Plugins.GetTextToSite(x.SubjectEn, x.SubjectFr, x.SubjectDefault));
            objX.WriteElementString("link", string.Format("http://{2}/CouponAddress.aspx?couponID={0}&SiteID={1}", x.ID, 6, drvvv.Plugins.GetTextToSite("anglodeals.co.il", "francodeals.co.il", "zebradeals.co.il")));
            objX.WriteElementString("pubDate", string.Format("{0:R}", x.EndDate));
            objX.WriteEndElement();
        }

        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();
        objX.Flush();
        objX.Close();
        Response.End();

    }
开发者ID:yschulmann,项目名称:Anglodeals,代码行数:35,代码来源:rss.aspx.cs

示例7: Main

    public static void Main()
    {
        string pathToSourceFile = "../../../albums.xml";
        string pathToTargetFile = "../../../album.xml";
        Encoding encoding = Encoding.GetEncoding("windows-1251");
        using (XmlReader reader = XmlReader.Create(pathToSourceFile))
        {
            using (XmlTextWriter writer = new XmlTextWriter(pathToTargetFile, encoding))
            {
                string name = "", artist = "";
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;
                writer.WriteStartDocument();
                writer.WriteStartElement("albums");

                while (reader.Read())
                {
                    if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "name"))
                    {
                        name = reader.ReadElementString();
                    }

                    if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "artist"))
                    {
                        artist = reader.ReadElementString();
                        WriteAlbum(writer, name, artist);
                    }
                }

                writer.WriteEndDocument();
            }
        }
    }
开发者ID:VelizarIT,项目名称:TelerikAcademy,代码行数:34,代码来源:XmlRedisigned.cs

示例8: DumpArrayToXml

	public void DumpArrayToXml ()
	{
		string metadata_filename = dir + Path.DirectorySeparatorChar + "album-data.xml";

		XmlTextWriter writer = new XmlTextWriter (metadata_filename, Encoding.UTF8);

		writer.WriteStartDocument (true);
		writer.WriteStartElement ("album", "www.ximian.com");
		writer.WriteAttributeString ("name", album_name);
	        writer.WriteAttributeString ("count", picture_count.ToString ());

		for (int i = 0; i < picture_count; ++i) {
			writer.WriteStartElement ("picture", "www.ximian.com");

			writer.WriteElementString ("location", "www.ximian.com", picture_data [i].Location);
			writer.WriteElementString ("title", "www.ximian.com", picture_data [i].Title);
			writer.WriteElementString ("date", "www.ximian.com", picture_data [i].Date);
			writer.WriteElementString ("keywords", "www.ximian.com", picture_data [i].Keywords);
			writer.WriteElementString ("comments", "www.ximian.com", picture_data [i].Comments);
			writer.WriteElementString ("index", "www.ximian.com", picture_data [i].Index.ToString ());
			
			writer.WriteEndElement ();
		}

		writer.WriteEndElement ();
		writer.WriteEndDocument ();
		writer.Close ();
	}
开发者ID:emtees,项目名称:old-code,代码行数:28,代码来源:Metadata.cs

示例9: Write

 public static void Write()
 {
     XmlTextWriter writer = new XmlTextWriter(Console.Out);
     writer.WriteStartDocument();
     writer.WriteElementString("Hello", "Xml");
     writer.WriteEndDocument();
     writer.Close();
 }
开发者ID:walrus7521,项目名称:code,代码行数:8,代码来源:Xml.cs

示例10: WriteRSSClosing

    public XmlTextWriter WriteRSSClosing(XmlTextWriter writer)
    {
        writer.WriteEndElement();
           writer.WriteEndElement();
           writer.WriteEndDocument();

           return writer;
    }
开发者ID:weavver,项目名称:weavver,代码行数:8,代码来源:Podcast.aspx.cs

示例11: WriteXmlReport

    public static void WriteXmlReport(IEnumerable<XmlReport> reports)
    {

        string fileName = "../../../Sales-by-Vendors-report.xml";
        Encoding encoding = Encoding.GetEncoding("windows-1251");
        using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
        {
            writer.Formatting = Formatting.Indented;
            writer.IndentChar = '\t';
            writer.Indentation = 1;

            writer.WriteStartDocument();
            writer.WriteStartElement("sales");

            string vendorName = "";
            bool isFirst = true;
            foreach (var report in reports)
            {
                if (report.VendorName !=vendorName && isFirst == true)
                {
                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", report.VendorName);

                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();

                    vendorName = report.VendorName;
                    isFirst = false;
                }
                else if (report.VendorName !=vendorName && isFirst == false)
                {
                    writer.WriteEndElement();
                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", report.VendorName);

                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();

                    vendorName = report.VendorName;
                }
                else
                {
                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();

            writer.WriteEndDocument();
        }
    }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:57,代码来源:XmlController.cs

示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        Response.ContentType = "application/xml";
        DataTable dt = CreateBll.GetInfo(TABLE_NAME, 1, 100);

        MemoryStream ms = new MemoryStream();
        XmlTextWriter xmlTW = new XmlTextWriter(ms, Encoding.UTF8);
        xmlTW.Formatting = Formatting.Indented;
        xmlTW.WriteStartDocument();
        xmlTW.WriteStartElement("urlset");
        xmlTW.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
        xmlTW.WriteAttributeString("xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9");

        foreach (DataRow dr in dt.Rows)
        {
            xmlTW.WriteStartElement("url");
            string infoUrl = CreateBll.GetInfoUrl(dr,1).ToLower();
            if(!infoUrl.StartsWith("http://")&&!infoUrl.StartsWith("https://")&&!infoUrl.StartsWith("ftp://"))
            {
                if(Param.ApplicationRootPath==string.Empty)
                {
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
                else
                {
                    infoUrl = infoUrl.Replace(Param.ApplicationRootPath.ToLower(),string.Empty);
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
            }
            xmlTW.WriteElementString("loc", infoUrl);

            xmlTW.WriteStartElement("news:news");
            xmlTW.WriteElementString("news:publication_date", dr["addtime"].ToString());
             string keywords = dr["tagnamestr"].ToString();
            if (keywords.StartsWith("|") && keywords.EndsWith("|"))
            {
                keywords = keywords.Substring(0, keywords.Length - 1);
                keywords = keywords.Substring(1, keywords.Length - 1);
                keywords = keywords.Replace("|",",");
            }
            xmlTW.WriteElementString("news:keywords", keywords);
            xmlTW.WriteEndElement();
            xmlTW.WriteEndElement();
        }
        xmlTW.WriteEndDocument();
        xmlTW.Flush();
        byte[] buffer = ms.ToArray();
        Response.Write(Encoding.UTF8.GetString(buffer));
        Response.End();
        xmlTW.Close();
        ms.Close();
        ms.Dispose();
    }
开发者ID:suizhikuo,项目名称:KYCMS,代码行数:54,代码来源:GoogleSiteMap.aspx.cs

示例13: CreateXmlFile

 public static void CreateXmlFile(string fileName, string rootElementName)
 {
     XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8);
     writer.WriteStartDocument();
     writer.Formatting = Formatting.Indented;
     writer.Indentation = 2;
     writer.WriteStartElement(rootElementName);
     writer.WriteEndElement();
     writer.WriteEndDocument();
     writer.Close();
 }
开发者ID:balamddine,项目名称:ChatAppSignalR,代码行数:11,代码来源:Convertor.cs

示例14: Main

    /// <summary>
    /// The entry point for the application.
    /// </summary>
    /// <param name="args"> A list of command line arguments</param>
    public static int Main(String[] args)
    {
        // TODO: Add code to start application here
        XmlTextWriter writer = new XmlTextWriter(Console.Out);
        writer.WriteStartDocument();
        writer.WriteElementString("Hello", "XML");
        writer.WriteEndDocument();
        writer.Close();

        return 0;
    }
开发者ID:dbremner,项目名称:hycs,代码行数:15,代码来源:helloXML.cs

示例15: Page_Load

    //===============================================================
    // Function: Page_Load
    //===============================================================
    protected void Page_Load(object sender, EventArgs e)
    {
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("data");

        CreateXMLContent(writer);

        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Close();
    }
开发者ID:sedogo,项目名称:Sedogo,代码行数:15,代码来源:timelineXML.aspx.cs


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