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


C# XmlTextWriter.WriteString方法代码示例

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


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

示例1: IssueLicense

        public string IssueLicense(DateTime expiry, string uniqueKey)
        {
            var sbXml = new StringBuilder();
            using (var swOut = new StringWriter(sbXml))
            using (var xmlOut = new XmlTextWriter(swOut))
            {
                xmlOut.WriteStartDocument();
                xmlOut.WriteStartElement("License");
                xmlOut.WriteStartElement("Key");
                xmlOut.WriteString(uniqueKey);
                xmlOut.WriteEndElement();
                xmlOut.WriteStartElement("IssueDate");
                xmlOut.WriteString(DateTime.Now
                    .ToString("dd/MM/yyyy HH:mm:ss"));
                xmlOut.WriteEndElement();
                xmlOut.WriteStartElement("Expires");
                xmlOut.WriteString(expiry
                    .ToString("dd/MM/yyyy HH:mm:ss"));
                xmlOut.WriteEndElement();
                xmlOut.WriteStartElement("IssuedBy");
                xmlOut.WriteString("Demo Licensing Server");
                xmlOut.WriteEndElement();
                xmlOut.WriteEndElement();
                xmlOut.WriteEndDocument();
                xmlOut.Close();
            }

            var privateKey = EncryptionUtils.GetRSAFromSnkFile("DemoPubPrivPair.snk");
            return SignAndVerify
            .SignXmlFile(sbXml.ToString(), privateKey);
        }
开发者ID:huoxudong125,项目名称:HQF.Tutorial.Encryption,代码行数:31,代码来源:LicenseServer.cs

示例2: SetXMLFromProperties

 //S'encarrega d'afegir al writer passat, el diccionari de propietats i els valors del component corresponent.
 public static void SetXMLFromProperties(String className, String[] arrayToGet, Dictionary<String, Object> dictProp, XmlTextWriter writer)
 {
     writer.WriteStartElement(AppConstants.DICT_TAGS[className]); //<component>
     for (int i = 0; i < arrayToGet.Length; i++)
     {
         writer.WriteStartElement(arrayToGet[i]);
         try
         {
             if (arrayToGet[i] == "DefaultIPGateway") //Si es la porta d'enllaç, agafarem el primer element del array.
             {
                 String[] array = (String[])dictProp[arrayToGet[i]];
                 writer.WriteString(array[0]);
             }
             else
             {
                 writer.WriteString(
                     //if
                     (dictProp[arrayToGet[i]] == null) ||
                     (dictProp[arrayToGet[i]].Equals("")) ||
                     (dictProp[arrayToGet[i]].Equals("0")) || //
                     (dictProp[arrayToGet[i]].Equals("N/A")) ? "N/A" :
                     //else
                     (dictProp[arrayToGet[i]].ToString().Trim())
                     );
             }
             writer.WriteEndElement();
         }
         catch (Exception)
         {
             writer.WriteString("N/A");
             writer.WriteEndElement();
         }
     }
     writer.WriteEndElement(); //</component>
 }
开发者ID:rgraf20,项目名称:systemAudit,代码行数:36,代码来源:XMLParser.cs

示例3: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            if (File.Exists("Favourite.xml"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("Favourite.xml");
                XmlNode webName = doc.CreateElement("WebsiteName");
                XmlNode web = doc.CreateElement("Website");

                web.InnerText = textBoxURL.Text;
                webName.InnerText = textBoxUrlName.Text;
                doc.DocumentElement.AppendChild(webName);
                doc.DocumentElement.AppendChild(web);
                doc.Save("Favourite.xml");
            }
            else
            {
                XmlTextWriter tw = new XmlTextWriter("Favourite.xml", Encoding.UTF8);
                tw.WriteStartElement("Favourite");
                tw.WriteStartElement("Website");
                tw.WriteStartElement("Name");
                tw.WriteString(textBoxURL.Text);
                tw.WriteString(textBoxUrlName.Text);

                tw.WriteEndElement();
                tw.WriteEndElement();
                tw.WriteEndElement();

                tw.Close();
            }
            MessageBox.Show("Favourite has been saved");
            this.Close();
        }
开发者ID:rgl1,项目名称:Web-Browser-CSHARP,代码行数:33,代码来源:Form2.cs

示例4: WriteToXml

        public static void WriteToXml(string filePath, List<KeyValuePair<string, List<string>>> myList)
        {
            var writer = new XmlTextWriter(filePath, Encoding.Unicode)
            {
                Formatting = Formatting.Indented,
                //Use indentation for readability.
                Indentation = 4
            };
            //writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
            //Write an element (this one is the root element).
            writer.WriteStartElement("ConnectionSettings");

            foreach (var keyValuePair in myList)
            {
                writer.WriteStartElement("Connection");
                writer.WriteString(keyValuePair.Key);
                writer.WriteEndElement();
                writer.WriteStartElement("UserName");
                writer.WriteString(keyValuePair.Value.First());
                writer.WriteEndElement();
                writer.WriteStartElement("VirtualProxy");
                writer.WriteString(keyValuePair.Value.Last());
                writer.WriteEndElement();
            }

            //Write the close tag for the root element.
            writer.WriteEndElement();

            //Write the XML to file and close the writer.
            writer.Close();
        }
开发者ID:AptkQlik,项目名称:QlikSenseScriptObfuscater,代码行数:31,代码来源:XmlHandler.cs

示例5: SaveAsXml

 public static void SaveAsXml(IEnumerable<Chapter> chapters, string path)
 {
     var writer = new XmlTextWriter(path, Encoding.GetEncoding("ISO-8859-1"));
     writer.Formatting = Formatting.Indented;
     writer.WriteStartDocument();
         writer.WriteDocType("Chapters", null, "matroskachapters.dtd", null);
         writer.WriteStartElement("Chapters");
             writer.WriteStartElement("EditionEntry");
             foreach (var chapter in chapters.Where(chapter => chapter.Keep))
             {
                 writer.WriteStartElement("ChapterAtom");
                     writer.WriteStartElement("ChapterTimeStart");
                         writer.WriteString(chapter.StartTimeXmlFormat); // 00:00:00.000
                     writer.WriteEndElement();
                     writer.WriteStartElement("ChapterDisplay");
                         writer.WriteStartElement("ChapterString");
                             writer.WriteString(chapter.Title); // Chapter 1
                         writer.WriteEndElement();
                         if (chapter.Language != null && chapter.Language != Language.Undetermined)
                         {
                             writer.WriteStartElement("ChapterLanguage");
                                 writer.WriteString(chapter.Language.ISO_639_2); // eng
                             writer.WriteEndElement();
                         }
                     writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteEndElement();
         writer.WriteEndElement();
     writer.WriteEndDocument();
     writer.Close();
 }
开发者ID:JGTM2016,项目名称:bdhero,代码行数:32,代码来源:MkvPropEdit.cs

示例6: CreateConfigurationFile

        public void CreateConfigurationFile()
        {
            // Deleting file if exists
            if (File.Exists(configFilename))
            {
                File.Delete(configFilename);
            }

            XmlTextWriter writer = new XmlTextWriter(configFilename, null);

            writer.Formatting = Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteStartElement(XML_TAG_OPENKM, "");                               // <openkm>
            writer.WriteStartElement(XML_TAG_HOST, "");                                 // <host>
            writer.WriteString(host);                                                   // host value
            writer.WriteEndElement();                                                   // </host>
            writer.WriteStartElement(XML_TAG_USER, "");                                 // <user>
            writer.WriteString(user);                                                   // user value
            writer.WriteEndElement();                                                   // </user>
            writer.WriteStartElement(XML_TAG_PASSWORD, "");                             // <password>
            writer.WriteString(Crypt.EncryptString(password, OPENKM_ENCRYPT_PASSWORD)); // password value
            writer.WriteEndElement();                                                   // </password>
            writer.WriteFullEndElement();                                               // </openkm>
            writer.WriteEndDocument();                                                  // EOF
            writer.Close();
        }
开发者ID:MG-Automation-Technologies,项目名称:dms,代码行数:26,代码来源:ConfigXML.cs

示例7: Main

		public static void Main (string[] args)
		{
			ArrayList problems;

			Validator v = new Validator ();
			Util.Verbosity = Util.DebugLevel.All;
			Util.Inform ("Loaded schema.");
			if (args.Length == 0) {
				Util.Inform ("Reading from standard input.");
				problems = v.ValidateString ("");
			} else {
				problems = v.Validate (args [0]);
			}

			if (XmlOutput) {
				XmlTextWriter w = new XmlTextWriter (Console.Out);
				w.WriteStartDocument ();
				w.WriteStartElement (null, "Problems", null);
				foreach (Problem p in problems)
				{
					w.WriteWhitespace ("\n");
					w.WriteStartElement (null, "Problem", null);

					w.WriteWhitespace ("\n");
					w.WriteStartElement (null, "Test", null);
					w.WriteString (p.Test);
					w.WriteEndElement ();

					w.WriteWhitespace ("\n");
					w.WriteStartElement (null, "Title", null);
					w.WriteString (p.Title);
					w.WriteEndElement ();

					w.WriteWhitespace ("\n");
					w.WriteStartElement (null, "Description", null);
					w.WriteString (p.Description);
					w.WriteEndElement ();

					w.WriteWhitespace ("\n");
					w.WriteStartElement (null, "Detail", null);
					w.WriteString (p.Detail);
					w.WriteEndElement ();

					w.WriteWhitespace ("\n");
					w.WriteEndElement ();
					w.WriteWhitespace ("\n");
				}
				w.WriteEndElement ();
				w.WriteWhitespace ("\n");
				w.WriteEndDocument ();

			} else {
				foreach (Problem p in problems)
				{
					Console.WriteLine (p.Title + " -- " + p.Description);
					Console.WriteLine (p.Detail);
				}
			}
		}
开发者ID:raosrinivasa,项目名称:doap,代码行数:59,代码来源:Main.cs

示例8: exportTopic

        public void exportTopic(string p_ID, Topic p_Topic)
        {
            Settings l_Settings = Settings.Instance;
            //File overwritten when already existing
            XmlTextWriter l_Writer = new XmlTextWriter(l_Settings.TopicsDir + p_ID + ".xml", Encoding.UTF8);
            l_Writer.Formatting = Formatting.Indented;

            try
            {
                l_Writer.WriteStartDocument();
                l_Writer.WriteComment("ggplot2 topic.");
                l_Writer.WriteStartElement("Topic");

                l_Writer.WriteStartElement("Title");
                l_Writer.WriteString(p_Topic.Title);
                l_Writer.WriteEndElement();
                l_Writer.WriteStartElement("ID");
                l_Writer.WriteString(p_Topic.ID);
                l_Writer.WriteEndElement();
                l_Writer.WriteStartElement("Messages");

                for (int j = 0; j < p_Topic.Messages.Count; j++)
                {
                    l_Writer.WriteStartElement("Message");
                    l_Writer.WriteStartElement("User");
                    l_Writer.WriteStartElement("Name");
                    l_Writer.WriteString(p_Topic.Messages[j].UserName);
                    l_Writer.WriteEndElement();
                    l_Writer.WriteStartElement("Avatar");
                    l_Writer.WriteString(p_Topic.Messages[j].Avatar);
                    l_Writer.WriteEndElement();
                    l_Writer.WriteStartElement("Email");
                    l_Writer.WriteString(p_Topic.Messages[j].Email);
                    l_Writer.WriteEndElement();
                    l_Writer.WriteEndElement();//~User
                    l_Writer.WriteStartElement("date");
                    l_Writer.WriteString(p_Topic.Messages[j].Date);
                    l_Writer.WriteEndElement();
                    l_Writer.WriteStartElement("content");
                    l_Writer.WriteString(p_Topic.Messages[j].Content);
                    l_Writer.WriteEndElement();
                    l_Writer.WriteEndElement();//~Message
                }

                l_Writer.WriteEndElement();//~Messages
                l_Writer.WriteEndElement();//~Topic

                l_Writer.WriteEndDocument();
                l_Writer.Flush();
                l_Writer.Close();
            }
            catch (Exception e)
            {
                l_Writer.Flush();
                l_Writer.Close();
                if (l_Settings.DebugMode)
                    debug("Exception in exportTopic(): " + e.Message);
            }
        }
开发者ID:josdemmers,项目名称:Master-Thesis,代码行数:59,代码来源:IOHandler.cs

示例9: OkButton_Click

        protected void OkButton_Click(object sender, EventArgs e)
        {
            string file = "C:\\Users\\Kiran\\Desktop\\Inventory.xml";
            if ((IdTextBox.Text == null) || (NameTextBox.Text == null) || (PriceTextBox.Text == null) || (QauntityTextBox.Text == null))
            {

                ErrorLabel.Visible = true;
            }
            else {
                CartObject item = new CartObject();
                item.itemId = IdTextBox.Text;
                item.itemName = NameTextBox.Text;
                item.itemPrice = Convert.ToDouble(PriceTextBox.Text);
                item.itemQuantity = Convert.ToUInt16(QauntityTextBox.Text);

                if (!File.Exists(file))
                {
                    XmlTextWriter xWriter = new XmlTextWriter(file, Encoding.UTF8);
                    xWriter.Formatting = Formatting.Indented;
                    xWriter.WriteStartElement("items");
                    xWriter.WriteStartElement("item");
                    xWriter.WriteStartElement("itemId");
                    xWriter.WriteString(item.itemId);
                    xWriter.WriteEndElement();
                    xWriter.WriteStartElement("itemName");
                    xWriter.WriteString(item.itemName);
                    xWriter.WriteEndElement();
                    xWriter.WriteStartElement("itemPrice");
                    xWriter.WriteString(Convert.ToString(item.itemPrice));
                    xWriter.WriteEndElement();
                    xWriter.WriteStartElement("itemQuantity");
                    xWriter.WriteString(Convert.ToString(item.itemQuantity));
                    xWriter.WriteEndElement();
                    xWriter.Close();
                }
                else
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(file);
                    XmlNode itemNode = doc.CreateElement("item");
                    XmlNode itemIdNode = doc.CreateElement("itemId");
                    itemIdNode.InnerText = item.itemId;
                    XmlNode itemNameNode = doc.CreateElement("itemName");
                    itemNameNode.InnerText = item.itemName;
                    XmlNode itemPriceNode = doc.CreateElement("itemPrice");
                    itemPriceNode.InnerText = Convert.ToString(item.itemPrice);
                    XmlNode itemQuantityNode = doc.CreateElement("itemQuantity");
                    itemQuantityNode.InnerText = Convert.ToString(item.itemQuantity);
                    itemNode.AppendChild(itemIdNode);
                    itemNode.AppendChild(itemNameNode);
                    itemNode.AppendChild(itemPriceNode);
                    itemNode.AppendChild(itemQuantityNode);
                    doc.DocumentElement.AppendChild(itemNode);
                    doc.Save(file);

                }

            }
        }
开发者ID:kiranprakash154,项目名称:SellingBooks,代码行数:59,代码来源:Inventory.aspx.cs

示例10: CreateTemplate

        public void CreateTemplate()
        {
            XmlTextWriter xmlWriter = new XmlTextWriter(kitFileLocation, null);
            xmlWriter.WriteStartDocument();
            //Add a template kit
            xmlWriter.WriteStartElement("kits"); //Parent
            xmlWriter.WriteStartElement("kit"); //Actual kit data

                xmlWriter.WriteStartElement("name");
                xmlWriter.WriteString("admins");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("description");
                xmlWriter.WriteString("Kit for Admins");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("item");
                xmlWriter.WriteAttributeString("id", "122");
                xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("kit");

                xmlWriter.WriteStartElement("name");
                xmlWriter.WriteString("builder");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("description");
                xmlWriter.WriteString("Kit for Builders");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("item");
                xmlWriter.WriteAttributeString("id", "58");
                xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("kit");

                xmlWriter.WriteStartElement("name");
                xmlWriter.WriteString("mod");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("description");
                xmlWriter.WriteString("Kit for Mods");
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("item");
                xmlWriter.WriteAttributeString("id", "58");
                xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndDocument();
            xmlWriter.Flush();
            xmlWriter.Close();
        }
开发者ID:Stickiler,项目名称:Essentials-TDSM,代码行数:57,代码来源:KitManager.cs

示例11: Main

 public static void Main(string[] args)
 {
     XmlTextWriter xmlTextWriter = new XmlTextWriter(Console.Out);
     xmlTextWriter.WriteStartDocument();
     xmlTextWriter.WriteString("articulo1");
     xmlTextWriter.WriteStartAttribute("nombre");
     xmlTextWriter.WriteString("Articulo uno");
     xmlTextWriter.Close();
 }
开发者ID:CarlosColoma,项目名称:PSP,代码行数:9,代码来源:Main.cs

示例12: ProcessRequest

        /// <summary>
        /// Generate the feed
        /// </summary>
        /// <param name="context">Encapsulate all HTTP-specific information about an individual HTTP request.</param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "text/xml";

            using (XmlWriter writerRss = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                writerRss.WriteStartDocument();
                writerRss.WriteStartElement("rss");
                writerRss.WriteAttributeString("version", "2.0");
                writerRss.WriteStartElement("channel");
                writerRss.WriteElementString("title", GlobalRessources.SiteName);
                writerRss.WriteStartElement("ImageUrl");
                writerRss.WriteElementString("Url", "Images/logo.png");
                writerRss.WriteElementString("title", GlobalRessources.SiteName);
                writerRss.WriteElementString("link", GlobalRessources.SiteUrl);
                writerRss.WriteEndElement();
                writerRss.WriteElementString("link", GlobalRessources.SiteUrl);
                writerRss.WriteElementString("description", "Retrouvez les dernières actualités de notre association.");

                IEnumerable<News> news = _webserviceNews.GetListNewsLimited(0, 15);

                foreach (News item in news)
                {
                    writerRss.WriteStartElement("item");

                    writerRss.WriteElementString("title", item.Title);

                    writerRss.WriteStartElement("description");
                    writerRss.WriteString(string.Format("<img src=\"{0}\" width=\"100\" height=\"113\" style=\"float: left\" />", item.ImageUrl));
                    writerRss.WriteString(item.Text);
                    writerRss.WriteEndElement();

                    writerRss.WriteElementString("link", string.Format("http://www.epsilab.net/News-{0}-{1}.aspx", item.Id, item.Url));
                    writerRss.WriteElementString("pubDate",  item.DateTime.ToString("f"));
                    writerRss.WriteElementString("author", string.Format("{0} {1}", item.Member.FirstName, item.Member.LastName));

                    writerRss.WriteEndElement();
                }

                writerRss.WriteEndElement();
                writerRss.WriteEndElement();
                writerRss.WriteEndDocument();

                writerRss.Flush();
                writerRss.Close();
            }

            context.Response.End();
        }
开发者ID:EPSILab,项目名称:SolarSystem-Jupiter,代码行数:54,代码来源:RSS.ashx.cs

示例13: createNode

 private void createNode(string pID, string pName, string pPrice, XmlTextWriter writer)
 {
     writer.WriteStartElement("Product");
     writer.WriteStartElement("Product_id");
     writer.WriteString(pID);
     writer.WriteEndElement();
     writer.WriteStartElement("Product_name");
     writer.WriteString(pName);
     writer.WriteEndElement();
     writer.WriteStartElement("Product_price");
     writer.WriteString(pPrice);
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
开发者ID:icegithub,项目名称:csharp-exercise,代码行数:14,代码来源:HowtocreateanXMLfileinCSharp.cs

示例14: Button1Click

        void Button1Click(object sender, EventArgs e)
        {
            string str_app = Application.StartupPath;
            XmlWriter XML = new XmlTextWriter(str_app + "\\WZextract_settings.xml", Encoding.Default);
                XML.WriteStartDocument();
                    XML.WriteStartElement("Settings");
                        XML.WriteStartElement("WZ_Files");
                            if (txtWZPath.Text != "") { XML.WriteString(txtWZPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("PNGs");
                            if (txtPNGPath.Text != "") { XML.WriteString(txtPNGPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("Map_Renders");
                            if (txtMapPath.Text != "") { XML.WriteString(txtMapPath.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("MP3s");
                            if (txtMP3Path.Text != "") { XML.WriteString(txtMP3Path.Text); } else { XML.WriteString("None"); }
                        XML.WriteEndElement();
                        XML.WriteStartElement("Resolve_UOLs");
                            XML.WriteValue(chkResolveUOL.Checked);
                        XML.WriteEndElement();
                        XML.WriteStartElement("Language");
                            XML.WriteValue(cmbLanguage.SelectedIndex);
                        XML.WriteEndElement();

                    XML.WriteEndElement();
                XML.WriteEndDocument();
            XML.Close();

            this.Close();
        }
开发者ID:davidyj,项目名称:starhome,代码行数:31,代码来源:pref.cs

示例15: BuildFeed

        protected override string BuildFeed()
        {
            StringWriter sw = new StringWriter();
            sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.WriteStartElement("creators");

            foreach(User user in GetCreators())
            {
                writer.WriteStartElement("creatorInfo");
                writer.WriteAttributeString("id", user.Name);
                writer.WriteElementString("name",  user.ProperName ?? string.Empty);

                writer.WriteStartElement("email");
                bool displayEmail = !string.IsNullOrEmpty(user.PublicEmail);
                writer.WriteAttributeString("display", displayEmail.ToString());
                writer.WriteString(user.PublicEmail);
                writer.WriteEndElement(); // End email

                writer.WriteElementString("bio", string.IsNullOrEmpty(user.Bio) ? string.Empty : Util.RemoveHtml(user.Bio, 200));
                writer.WriteElementString("url", user.WebSite ?? string.Empty);
                writer.WriteEndElement(); // End creatorInfo
            }

            writer.WriteEndElement(); // End creators

            return sw.ToString();
        }
开发者ID:chartek,项目名称:graffiticms,代码行数:29,代码来源:CreatorWriter.cs


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