• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# XmlTextWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string folderpath = @"/var/www/weavver.com/messages";
          if (!Directory.Exists(folderpath))
              return;

          XmlTextWriter writer    = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
          writer.Indentation      = 5;
          writer.Formatting       = Formatting.Indented;
          WriteRSSPrologue(writer);
          int i = 0;

          Random r = new Random(10);
          foreach (string file in System.IO.Directory.GetFiles(folderpath))
          {
               if (file.EndsWith("wav"))
               {
                    string num = r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString() + "-" + r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString() + r.Next(10).ToString();
                    AddRSSItem(writer, "Jane Doe left you a message from 714-" + num, file, System.IO.Path.GetFileName(file), DateTime.Now.Subtract(TimeSpan.FromDays(i)).ToString("r"));
                    i++;
               }
               if (i > 10)
               {
                    break;
               }
          }
          WriteRSSClosing(writer);
          writer.Flush();
          writer.Close();

          Response.ContentEncoding = System.Text.Encoding.UTF8;
          Response.ContentType     = "text/xml";
          Response.Cache.SetCacheability(HttpCacheability.Private);
          Response.End();
    }
开发者ID:weavver,项目名称:weavver,代码行数:35,代码来源:Podcast.aspx.cs


示例4: Images

    private void Images()
    {
         // Dataset containing 
        string catname ="Electricals";
        ProductImageService.serProdctImage prodimage = new ProductImageService.serProdctImage();
        DataSet dataset = prodimage.ProductImage_GetFashImgtwoForHandler(catname);
        //string x = dataset.GetXml();
        string xmlfile = dataset.GetXml();

        XslTransform xslt = new XslTransform();
        xslt.Load(Server.MapPath("~/xslt/HomeXSLTFile.xslt"));
        XPathDocument xpathdocument = new
        XPathDocument(xmlfile);
        XmlTextWriter writer = new XmlTextWriter(Console.Out);
        writer.Formatting = Formatting.Indented;

        xslt.Transform(xpathdocument, null, writer, null);
        


        //strstudentDetails = GetHtml(Server.MapPath("~/xsl/studentDetails.xsl"), strXML);

        //XPathDocument myXPathDoc = new XPathDocument(myXmlFile);
        //XslCompiledTransform myXslTrans = new XslCompiledTransform();
        //myXslTrans.Load(myStyleSheet);
        //XmlTextWriter myWriter = new XmlTextWriter("result.html", null);
        //myXslTrans.Transform(myXPathDoc, null, myWriter);
     }
开发者ID:chsarpong,项目名称:MahaplastWebApp_19.9.2012,代码行数:28,代码来源:HomeXSLT.aspx.cs


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


示例6: WriteOutput

    public static void WriteOutput(object data, Stream output, bool closeStreams )
    {
        if (data == output) return;

        XmlDocument xml = data as XmlDocument;
        if (xml != null)
        {
            XmlTextWriter xmlWriter = new XmlTextWriter(output, System.Text.Encoding.UTF8);
            xml.WriteTo(xmlWriter);
            xmlWriter.Flush();
        }

        Stream stream = data as Stream;
        if (stream != null)
        {
            stream.Seek(0, SeekOrigin.Begin);
            byte[] buffer = new byte[0x5000];
            int read;
            while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
                output.Write(buffer, 0, read);

            if ( closeStreams ) stream.Close();
        }

        byte[] block = data as byte[];
        if ( block != null && block.Length > 0 )
            output.Write( block, 0, block.Length );
    }
开发者ID:mbsky,项目名称:kub-engine,代码行数:28,代码来源:Types.cs


示例7: Main

    /* 08. Write a program, which (using XmlReader and XmlWriter) reads the file catalog.xml 
     * and creates the file album.xml, in which stores in appropriate way 
     * the names of all albums and their authors.*/

    static void Main(string[] args)
    {
        using (XmlReader reader = XmlReader.Create("../../catalog.xml"))
        {
            string fileName = "../../albums.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("albums");
                var title = string.Empty;
                var artist = string.Empty;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == "name")
                        {
                            title = reader.ReadElementString();
                        }
                        else if (reader.Name == "artist")
                        {
                            artist = reader.ReadElementString();
                            WriteAlbum(writer, title, artist);
                        }
                    }
                }
            }
        }
    }
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:39,代码来源:CreatingAlbumXML.cs


示例8: Xml

 public static string Xml(this XElement e)
 {
     StringBuilder builder = new StringBuilder();
     XmlTextWriter writer = new XmlTextWriter(new StringWriter(builder));
     e.WriteTo(writer);
     return builder.ToString();
 }
开发者ID:haimon74,项目名称:KanNaim,代码行数:7,代码来源:ExtensionFunctions.cs


示例9: DeserializeObject

 // Here we deserialize it back into its original form
 object DeserializeObject(string pXmlizedString)
 {
     XmlSerializer xs = new XmlSerializer(typeof(UserData));
     MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString));
     XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
     return xs.Deserialize(memoryStream);
 }
开发者ID:rubabuddin,项目名称:3d-freehand-input,代码行数:8,代码来源:_GameLoad.cs


示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime now = DateTime.Now;
        Organization org = Organization.FromIdentity(Int32.Parse(Request.QueryString["OrganizationId"]));

        ExternalActivities activities = ExternalActivities.ForOrganization(org);
        activities.Sort(ExternalActivities.SortOrder.DateDescending);

        Response.ContentType = "text/xml";

        XmlWriter xml = new XmlTextWriter(Response.Output);
        RssWriter rss = new RssWriter(xml);

        rss.WriteHeader("Aktivism - " + org.Name, "http://www.piratpartiet.se", "Aktivism för Piratpartiet", null);

        foreach (ExternalActivity activism in activities)
        {
            string title = "Aktivism i " + activism.Geography.Name;
            if (title.Length > 60)
            {
                title = title.Substring(0, 57) + "...";
            }

            rss.WriteItem(title, "<img src=\"http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity.ToString() + "\" />", new Uri("http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity), activism.CreatedDateTime);
        }

        rss.Close();
        xml.Close();
    }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:29,代码来源:Activism.aspx.cs


示例11: Main

    public static int Main(string[] args)
    {
        if (args.Length < 1) {
            Console.Error.WriteLine("Usage: RunMorphoCli tagger_file");
            return 1;
        }

        Console.Error.Write("Loading tagger: ");
        Tagger tagger = Tagger.load(args[0]);
        if (tagger == null) {
            Console.Error.WriteLine("Cannot load tagger from file '{0}'", args[0]);
            return 1;
        }
        Console.Error.WriteLine("done");

        Forms forms = new Forms();
        TaggedLemmas lemmas = new TaggedLemmas();
        TokenRanges tokens = new TokenRanges();
        Tokenizer tokenizer = tagger.newTokenizer();
        if (tokenizer == null) {
            Console.Error.WriteLine("No tokenizer is defined for the supplied model!");
            return 1;
        }

        XmlTextWriter xmlOut = new XmlTextWriter(Console.Out);
        for (bool not_eof = true; not_eof; ) {
            string line;
            StringBuilder textBuilder = new StringBuilder();

            // Read block
            while ((not_eof = (line = Console.In.ReadLine()) != null) && line.Length > 0) {
                textBuilder.Append(line).Append('\n');
            }
            if (not_eof) textBuilder.Append('\n');

            // Tokenize and tag
            string text = textBuilder.ToString();
            tokenizer.setText(text);
            int t = 0;
            while (tokenizer.nextSentence(forms, tokens)) {
                tagger.tag(forms, lemmas);

                for (int i = 0; i < lemmas.Count; i++) {
                    TaggedLemma lemma = lemmas[i];
                    int token_start = (int)tokens[i].start, token_length = (int)tokens[i].length;
                    xmlOut.WriteString(text.Substring(t, token_start - t));
                    if (i == 0) xmlOut.WriteStartElement("sentence");
                    xmlOut.WriteStartElement("token");
                    xmlOut.WriteAttributeString("lemma", lemma.lemma);
                    xmlOut.WriteAttributeString("tag", lemma.tag);
                    xmlOut.WriteString(text.Substring(token_start, token_length));
                    xmlOut.WriteEndElement();
                    if (i + 1 == lemmas.Count) xmlOut.WriteEndElement();
                    t = token_start + token_length;
                }
            }
            xmlOut.WriteString(text.Substring(t));
        }
        return 0;
    }
开发者ID:ufal,项目名称:morphodita,代码行数:60,代码来源:RunTagger.cs


示例12: WriteGestureLog

            public void WriteGestureLog(Dictionary<String, Point3D> gestureDict, string timeStamp)
            {
                using (StringWriter sw = new StringWriter(_sBuilder))
                {
                    using (XmlWriter xmlWriter = new XmlTextWriter(sw))
                    {
                        //START MOVEMENT
                        xmlWriter.WriteStartElement("mov");
                        xmlWriter.WriteStartAttribute("time_stamp");
                        xmlWriter.WriteValue(timeStamp);
                        xmlWriter.WriteEndAttribute();
                        //PRINT ALL JOINTS
                        foreach (var point in gestureDict)
                        {
                            xmlWriter.WriteStartElement(point.Key);//START JOINT
                            xmlWriter.WriteStartElement("x");
                            xmlWriter.WriteValue(point.Value.X);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Y");
                            xmlWriter.WriteValue(point.Value.Y);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Z");
                            xmlWriter.WriteValue(point.Value.Z);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndElement();//END JOINT
                        }
                        xmlWriter.WriteEndElement();//END MOV
                    }

                }
                WriteToXMLLogFile();
            }
开发者ID:saflogar,项目名称:GestureTrainingInterface,代码行数:32,代码来源:XMLLoggerSingleton.cs


示例13: WriteBookmarks

	private static void WriteBookmarks(
		XmlTextWriter writer, IList<Bookmark> bookmarks)
	{
		writer.WriteStartElement("result-set");
		foreach (var bookmark in bookmarks)
		{
			writer.WriteStartElement("bookmark");
			if (bookmark.User.Username != null)
			{
				writer.WriteElementString("username", bookmark.User.Username);
			}
			if (bookmark.Title != null)
			{
				writer.WriteElementString("title", bookmark.Title);
			}
			if (bookmark.URL != null)
			{
				writer.WriteElementString("url", bookmark.URL);
			}
			if (bookmark.Tags.Count > 0)
			{
				string tags = string.Join(", ",
					bookmark.Tags.Select(t => t.Name).OrderBy(t => t));
				writer.WriteElementString("tags", tags);
			}
			if (bookmark.Notes != null)
			{
				writer.WriteElementString("notes", bookmark.Notes);
			}
			writer.WriteEndElement();
		}
		writer.WriteEndElement();
	}
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:33,代码来源:BookmarksComplexSearch.cs


示例14: ProcessSearchQueries

	private static void ProcessSearchQueries(XmlTextWriter writer)
	{
		XmlDocument xmlDoc = new XmlDocument();
		xmlDoc.Load("../../complex-query.xml");
		foreach (XmlNode query in xmlDoc.SelectNodes("/queries/query"))
		{
			string username = query.GetChildText("username");
			int maxResults = 10;
			var maxResultsAttrib = query.Attributes["max-results"];
			if (maxResultsAttrib != null)
			{
				maxResults = int.Parse(maxResultsAttrib.Value);
			}
			List<string> tags = new List<string>();
			foreach (XmlNode tag in query.SelectNodes("tag"))
			{
				tags.Add(tag.InnerText.Trim());
			}

			var bookmarks =
				BookmarksDAL.FindBookmarks(username, tags, maxResults);

			WriteBookmarks(writer, bookmarks);
		}		
	}
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:25,代码来源:BookmarksComplexSearch.cs


示例15: ComplexSearch

    static void ComplexSearch(XmlTextWriter writer)
    {
        BookstoreEntities context = new BookstoreEntities();
        using (context)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(Bookstore.Data.Settings.Default.complexSearchReadFile);
            XmlNodeList queries = doc.SelectNodes("/review-queries/query");
            foreach (XmlNode query in queries)
            {
                string type = query.Attributes["type"].Value;
                if (type == "by-period")
                {
                    string start = query.SelectSingleNode("start-date").InnerText;
                    string end = query.SelectSingleNode("end-date").InnerText;
                    IList<Review> found =
                        BookstoreDAL.FindReviewPeriod(start, end, context);
                    WriteResultSet(writer, found);
                }
                else if (type == "by-author")
                {
                    string author = query.SelectSingleNode("author-name").InnerText;
                    IList<Review> found =
                        BookstoreDAL.FindReviewAuthor(author, context);
                    WriteResultSet(writer, found);
                }

                SearchLogsImporter.AddLog(DateTime.Now, query.OuterXml);
            }
        }
    }
开发者ID:vasilkrvasilev,项目名称:Databases,代码行数:31,代码来源:DataSearcher.cs


示例16: TreverseDirectories

    private static void TreverseDirectories(XmlTextWriter writer, DirectoryInfo dir)
    {
        var folders = dir.GetDirectories();
        var files = dir.GetFiles();
        writer.WriteStartElement("folder");
        writer.WriteElementString("name", dir.Name);

        try
        {
            if (files.Count() > 0)
            {
                writer.WriteStartElement("files");
                foreach (var file in files)
                {
                    writer.WriteElementString("name", file.Name);
                }

                writer.WriteEndElement();
            }

            foreach (var child in folders)
            {
                TreverseDirectories(writer, child);
            }

            writer.WriteEndElement();
        }
        catch (Exception)
        {
            Console.WriteLine("Access denied! ");
        }
    }
开发者ID:aleks-todorov,项目名称:HomeWorks,代码行数:32,代码来源:TraversingDirectory.cs


示例17: Action

    public void Action() {   
        string xml = "<?xml version=\"1.0\"?>\n<a><b c=\"d\">e</b></a>";
        string xsl = "<?xml version=\"1.0\"?>\n" +
            "<xsl:stylesheet version=\"1.0\" " +
                    "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" " +
                    "xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" " +
                    "xmlns:js=\"urn:js\" " +
                ">" +
                "<msxsl:script language=\"jsCrIpt\" implements-prefix=\"js\">" +
                    "function SimpleTest() { return \"JScript test\"; }" +        
                "</msxsl:script>" +                
                "<xsl:template match=\"a\"><foo><xsl:apply-templates/></foo></xsl:template>" +
                "<xsl:template match=\"b\"><xsl:element name=\"bar\">" +
        	        "<xsl:attribute name=\"simpleTest\"><xsl:value-of select=\"js:SimpleTest()\"/></xsl:attribute>" +
                "</xsl:element></xsl:template>" +
                "<xsl:template match=\"/\"><xsl:apply-templates/></xsl:template>" +
            "</xsl:stylesheet>";            
    
        XPathDocument myXPathDocument = new XPathDocument(new XmlTextReader(new StringReader(xml)));

        XslTransform myXslTransform = new XslTransform();
        myXslTransform.Load(new XmlTextReader(new StringReader(xsl)));
        
        StringWriter myStringWriter = new StringWriter();
        XmlTextWriter myXmlWriter = new XmlTextWriter(myStringWriter);
        myXmlWriter.Formatting = Formatting.Indented;
        
        myXslTransform.Transform(myXPathDocument, null, myXmlWriter);
        myXmlWriter.Close();        
        
        Console.WriteLine(myStringWriter.ToString());
    }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:32,代码来源:appdomainstress.cs


示例18: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime now = DateTime.Now;

        MediaEntries entries = (MediaEntries) Cache.Get(cacheKey);

        if (entries == null)
        {
            entries = MediaEntries.FromBlogKeyword("Piratpartiet", now.AddDays(-7));
            Cache.Insert(cacheKey, entries, null, DateTime.UtcNow.AddMinutes (5) , System.Web.Caching.Cache.NoSlidingExpiration); // five minute cache is plenty to prevent db F5 attacks
        }
      
        Response.ContentType = "text/xml";

        XmlWriter xml = new XmlTextWriter(Response.Output);
        RssWriter rss = new RssWriter(xml);

        rss.WriteHeader("Bloggat om Piratpartiet", "http://www.piratpartiet.se", "Bloggposter som nämner Piratpartiet", null);

        foreach (MediaEntry entry in entries)
        {
            string title = entry.Title;
            if (title.Length > 30)
            {
                title = title.Substring(0, 27) + "...";
            }

            rss.WriteItem(title, string.Empty, new Uri (entry.Url), entry.DateTime);
        }

        rss.Close();
        xml.Close();
    }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:33,代码来源:PiratpartietRss.aspx.cs


示例19: AddURL

 private void AddURL(XmlTextWriter writer, string siteUrl, string url, DateTime dateUpdate)
 {
     writer.WriteStartElement("url");
     writer.WriteElementString("loc", siteUrl + url);
     writer.WriteElementString("lastmod", String.Format("{0:yyyy-MM-dd}", dateUpdate));
     writer.WriteEndElement();
 }
开发者ID:ivladyka,项目名称:OurTravels,代码行数:7,代码来源:SiteMap.aspx.cs


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# XmlTypeCode类代码示例发布时间:2022-05-24
下一篇:
C# XmlTextReader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap