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


C# XmlTextWriter.WriteStartAttribute方法代码示例

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


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

示例1: WriteMyAssetSet

        static void WriteMyAssetSet(FileInfo[] files)
        {
            string shortfile;

            XmlTextWriter xmlwriter = new XmlTextWriter("MyAssetSet.xml", null);

            xmlwriter.Formatting = System.Xml.Formatting.Indented;
            xmlwriter.IndentChar = ' ';
            xmlwriter.Indentation = 2;

            xmlwriter.WriteStartElement("Nini");

            foreach (FileInfo f in files)
            {
                shortfile = Path.GetFileNameWithoutExtension(f.FullName);

                xmlwriter.WriteStartElement("Section");
                xmlwriter.WriteStartAttribute("Name");
                xmlwriter.WriteValue(shortfile);
                xmlwriter.WriteEndAttribute();

                WriteKey(xmlwriter, "assetID", shortfile);
                WriteKey(xmlwriter, "name", shortfile);
                WriteKey(xmlwriter, "assetType", "0");
                WriteKey(xmlwriter, "inventoryType", "0");
                WriteKey(xmlwriter, "fileName", f.Name);

                xmlwriter.WriteEndElement();
            }

            xmlwriter.WriteEndElement();
            xmlwriter.Close();
        }
开发者ID:SObS,项目名称:AssetCompiler,代码行数:33,代码来源:AssetCompiler.cs

示例2: WriteXml

		///	<summary>
		///	写 XML
		///	</summary>
		public void	WriteXml()
		{
			// 构造写入类.
			// 第一个参数为 文件名
			// 第二个参数为编码方式.
			XmlTextWriter writer = new XmlTextWriter(XML_FILE_NAME,	Encoding.UTF8);

			//使用自动缩进便于阅读
			writer.Formatting =	Formatting.Indented;

			// 书写版本为“1.0”的 XML 声明
			writer.WriteStartDocument();


			// 写注释
			writer.WriteComment("XML文件写入的例子!");

			//写入根元素
			writer.WriteStartElement("items");

			// 加入属性: type="IT"
			writer.WriteStartAttribute("type");
			writer.WriteString("information");
			writer.WriteEndAttribute();

			writer.WriteStartAttribute("keyword");
			writer.WriteString("Database");
			writer.WriteEndAttribute();


			// 加入子元素: <title>SQL Server</title>	这种方式的。
			writer.WriteElementString("title", "SQL	Server");
			writer.WriteElementString("title", "Oracle");
			writer.WriteElementString("title", "MySQL");


			//关闭根元素,并书写结束标签
			writer.WriteEndElement();

			// 关闭任何打开的元素或属性
			writer.WriteEndDocument();

			//将XML写入文件并且关闭XmlTextWriter
			writer.Close();
		}
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:48,代码来源:XmlWriteRead.cs

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

示例4: SaveToFile

 public void SaveToFile(string text1)
 {
     XmlTextWriter writer = null;
     writer = new XmlTextWriter(text1, Encoding.Default);
     writer.Formatting = Formatting.Indented;
     writer.WriteStartDocument();
     writer.WriteStartElement("root");
     writer.WriteStartElement("BetSuccessSwitching");
     writer.WriteStartAttribute("IsBetSuccessSwitchingEnable");
     writer.WriteValue(Conversion.Val(this._isBetSuccessSwitchingEnable).ToString());
     writer.WriteEndAttribute();
     writer.WriteStartAttribute("BetSuccessSwitchingValue");
     writer.WriteValue(this._objBetSuccessSwitchingOpotion.get_SwitchingValue().ToString());
     writer.WriteEndAttribute();
     writer.WriteEndElement();
     writer.Flush();
     writer.Close();
 }
开发者ID:yjtang,项目名称:AutoBws,代码行数:18,代码来源:AccountSwitchingOptionCollection.cs

示例5: addAtributeToXml

 public void addAtributeToXml(XmlTextWriter t, string name, string text)
 {
     if (text == null)
     {
         text = "";
     }
     t.WriteStartAttribute(name);
     t.WriteString(text);
     t.WriteEndAttribute();
 }
开发者ID:Yaponiz,项目名称:AdvertBase,代码行数:10,代码来源:authuser.cs

示例6: Save

        public static void Save()
        {
            string file = Path.Combine(Paths.ConfigDirectory, ConfigFile);
            XmlTextWriter xmlWriter = new XmlTextWriter(file, Encoding.UTF8);
            xmlWriter.Formatting = Formatting.Indented;

            xmlWriter.WriteStartElement("proxy-settings");

            // Proxy
            xmlWriter.WriteStartElement("proxy");

            // Enabled
            xmlWriter.WriteStartAttribute("enabled");
            xmlWriter.WriteString(EnableProxy.ToString());
            xmlWriter.WriteEndAttribute();

            if (EnableProxy == true) {
                // Set Host
                xmlWriter.WriteStartAttribute("host");
                xmlWriter.WriteString(Host);
                xmlWriter.WriteEndAttribute();

                // Set Port
                xmlWriter.WriteStartAttribute("port");
                xmlWriter.WriteString(Port.ToString());
                xmlWriter.WriteEndAttribute();
            }
            xmlWriter.WriteEndElement();

            // Proxy Auth
            xmlWriter.WriteStartElement("auth");

            // Enabled
            xmlWriter.WriteStartAttribute("enabled");
            xmlWriter.WriteString(UseProxyAuth.ToString());
            xmlWriter.WriteEndAttribute();

            if (UseProxyAuth == true) {
                // Set Host
                xmlWriter.WriteStartAttribute("username");
                xmlWriter.WriteString(Username);
                xmlWriter.WriteEndAttribute();

                // Set Port
                xmlWriter.WriteStartAttribute("password");
                xmlWriter.WriteString(Password);
                xmlWriter.WriteEndAttribute();
            }
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();
            xmlWriter.Close();
        }
开发者ID:BackupTheBerlios,项目名称:nyiv,代码行数:52,代码来源:Proxy.cs

示例7: SaveParameters

        public static void SaveParameters()
        {
            try
            {
                XmlTextWriter writer = new XmlTextWriter("params.xml", System.Text.Encoding.UTF8);

                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();

                writer.WriteStartElement("RegionEditor");

                if (MulPath != "")
                {
                    writer.WriteStartElement("mulpath");

                    writer.WriteStartAttribute("path");
                    writer.WriteValue(_MulPath);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                if (RegionsFile != "")
                {
                    writer.WriteStartElement("script");

                    writer.WriteStartAttribute("file");
                    writer.WriteValue(_RegionsFile);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                if (Compatibility)
                {
                    writer.WriteStartElement("client");

                    writer.WriteStartAttribute("compatibilitymode");
                    writer.WriteValue(Compatibility);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteEndDocument();

                writer.Close();
            }
            catch { }
        }
开发者ID:frkdom,项目名称:Region-Editor-2015,代码行数:52,代码来源:Parameters.cs

示例8: Encode

		/// <summary>
		/// Encodes any special characters in the xml string.
		/// </summary>
		public static string Encode(string xml, char quoteCharacter)
		{
			XmlEncoderTextWriter encoderWriter = new XmlEncoderTextWriter();
			using (XmlTextWriter writer = new XmlTextWriter(encoderWriter)) {
				writer.WriteStartElement("root");
				writer.WriteStartAttribute("attribute");
				writer.QuoteChar = quoteCharacter;
				
				encoderWriter.BeginMarkup();
				writer.WriteString(xml);
				return encoderWriter.Markup;
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:16,代码来源:XmlEncoder.cs

示例9: Save

        public static void Save(string file)
        {
            using (var writer = new XmlTextWriter(file, Encoding.UTF8))
            {
                writer.WriteStartElement("configuration");
                writer.WriteStartElement("connectionstring");
                writer.WriteStartAttribute("ip");
                writer.WriteString(IP);
                writer.WriteEndAttribute();

                writer.WriteStartAttribute("user");
                writer.WriteString(User);
                writer.WriteEndAttribute();

                writer.WriteStartAttribute("password");
                writer.WriteString(Password);
                writer.WriteEndAttribute();

                writer.WriteStartAttribute("database");
                writer.WriteString(Database);
                writer.WriteEndAttribute();
            }
        }
开发者ID:mkozhevnikov,项目名称:Auto,代码行数:23,代码来源:ServerInfo.cs

示例10: TraverseRootDirectoryRecursively

        private static void TraverseRootDirectoryRecursively(XmlTextWriter writer, DirectoryInfo rootDirectory)
        {
            if (!rootDirectory.GetFiles().Any() && !rootDirectory.GetDirectories().Any())
            {
                return;
            }

            writer.WriteStartElement("dir");
            writer.WriteStartAttribute("name", rootDirectory.Name);

            foreach (var file in rootDirectory.GetFiles())
            {
                writer.WriteStartElement("file");
                writer.WriteStartAttribute("name", file.Name);
                writer.WriteEndElement();
            }

            foreach (var directory in rootDirectory.GetDirectories())
            {
                TraverseRootDirectoryRecursively(writer, directory);
            }

            writer.WriteEndElement();
        }
开发者ID:EmilMitev,项目名称:Telerik-Academy,代码行数:24,代码来源:Task09.cs

示例11: SaveTaskHistoryToXMLFile

        /// <summary>
        /// Сохранение истории задачи в отдельный XML-файл
        /// </summary>
        /// <param name="taskname">Название задачи</param>
        /// <param name="his">История задачи</param>
        /// <param name="fname">Полный путь и имя файла для сохранения</param>
        public static void SaveTaskHistoryToXMLFile(string taskname, THistory[] his, string fname)
        {
            XmlTextWriter file = new XmlTextWriter(fname, Encoding.UTF8);

            file.WriteStartDocument();
            file.WriteComment("Definition of task history data");
            file.WriteStartElement("history");
            file.WriteStartAttribute("taskname");
            file.WriteValue(taskname);
            for (int i = 0; i < his.Length; i++)
            {
                file.WriteStartElement("helement");
                file.WriteStartAttribute("date");
                file.WriteValue(his[i].Date);
                file.WriteStartAttribute("type");
                file.WriteValue(his[i].Type.ToString());
                file.WriteStartAttribute("value");
                file.WriteValue(his[i].Value);
                file.WriteEndElement();
            }
            file.WriteEndElement();

            file.Close();
        }
开发者ID:Digiman,项目名称:MyToDoApp,代码行数:30,代码来源:XMLWorker.cs

示例12: SaveLabelsCacheToXMLFile

        /// <summary>
        /// Запись кэша меток в отдельный XML файл
        /// </summary>
        /// <param name="buf">Кэш меток</param>
        /// <param name="fname">Полный путь и название файла для сохранения</param>
        public static void SaveLabelsCacheToXMLFile(LabelsCache buf, string fname)
        {
            XmlTextWriter file = new XmlTextWriter(fname, Encoding.UTF8);

            file.WriteStartDocument();
            file.WriteComment("Definition of labels cache data");
            file.WriteStartElement("labels");
            for (int i = 0; i < buf.GetLabelsCount; i++)
            {
                file.WriteStartElement("label");
                file.WriteStartAttribute("value");
                file.WriteValue(buf[i]);
                file.WriteEndElement();
            }
            file.WriteEndElement();

            file.Close();
        }
开发者ID:Digiman,项目名称:MyToDoApp,代码行数:23,代码来源:XMLWorker.cs

示例13: writeTicketLoad

        /// <summary>
        /// Constructs the ticket payload.
        /// </summary>
        /// <param name="rootElement"></param>
        /// <param name="ticketType"></param>
        /// <param name="keyValueDictionary"></param>
        /// <returns></returns>
        public string writeTicketLoad(string rootElement, string ticketType, Dictionary<string, object> keyValueDictionary)
        {
            try
            {
                StringWriter stringWriter = new StringWriter();
                XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
                //xmlWriter.Formatting = Formatting.Indented;
                //xmlWriter.Indentation = indentation;

                // write root element
                xmlWriter.WriteStartElement(rootElement);
                xmlWriter.WriteAttributeString("xmlns", "ns", null, ticketNS);

                // write ticket type
                xmlWriter.WriteStartAttribute("ticketType");
                xmlWriter.WriteString(ticketType);
                xmlWriter.WriteEndAttribute();

                foreach (string s in keyValueDictionary.Keys)
                {
                    xmlWriter.WriteStartElement(s);
                    object value = new object();
                    keyValueDictionary.TryGetValue(s, out value);
                    xmlWriter.WriteString(value.ToString());
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndElement();
                return stringWriter.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            return null;
        }
开发者ID:gumpyoung,项目名称:ilabproject-code,代码行数:45,代码来源:BasicTicketLoadFactory.cs

示例14: WriteMySiteLibraryFolders

        static void WriteMySiteLibraryFolders(string folderID)
        {
            XmlTextWriter xmlwriter = new XmlTextWriter("MySiteLibraryFolders.xml", null);

            xmlwriter.Formatting = System.Xml.Formatting.Indented;
            xmlwriter.IndentChar = ' ';
            xmlwriter.Indentation = 2;

            xmlwriter.WriteStartElement("Nini");
            xmlwriter.WriteStartElement("Section");
            xmlwriter.WriteStartAttribute("Name");
            xmlwriter.WriteValue("MySiteLibraryFolder");
            xmlwriter.WriteEndAttribute();

            WriteKey(xmlwriter, "folderID", folderID);
            WriteKey(xmlwriter, "parentFolderID", "00000112-000f-0000-0000-000100bba000");
            WriteKey(xmlwriter, "name", "MySiteLibraryFolder");
            WriteKey(xmlwriter, "type", "0");

            xmlwriter.WriteEndElement();
            xmlwriter.WriteEndElement();
            xmlwriter.Close();
        }
开发者ID:SObS,项目名称:AssetCompiler,代码行数:23,代码来源:AssetCompiler.cs

示例15: CommandBinding_NewCmdExecuted

        private void CommandBinding_NewCmdExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            MogitorsRoot mogRoot = MogitorsRoot.Instance;
            if (!(mogRoot.TerminateScene()))
                return;

            ProjectOptions opt = mogRoot.ProjectOptions;
            opt.IsNewProject = true;
            opt.ProjectName = "";
            opt.ProjectDir = MogitorsSystem.Instance.ProjectsDirectory;
            opt.SceneManagerName = "OctreeSceneManager";
            opt.TerrainDirectory = "Terrain";
            opt.ResourceDirectories.Clear();
            opt.Cameras.Clear();
            opt.SelectionBBColourForSerializer = Color.FromRgb(255, 255, 255);
            opt.HighlightBBColourForSerializer = Color.FromRgb(232, 48, 48);

            SettingsDialog dlg = new SettingsDialog(opt);
            if (dlg.ShowDialog() == true)
            {
                string fileName = MogitorsSystem.Instance.CombinePath(mogRoot.ProjectOptions.ProjectDir, mogRoot.ProjectOptions.ProjectName + ".mogscene");
                fileName = MogitorsSystem.Instance.GetFullPath(fileName);

                XmlTextWriter textWriter = new XmlTextWriter(fileName, System.Text.Encoding.Unicode);
                textWriter.Formatting = Formatting.Indented;
                textWriter.WriteStartDocument();

                // XML Root
                textWriter.WriteStartElement("MogitorScene");

                // Write project options
                mogRoot.WriteProjectOptions(textWriter, true);

                // Write new scene definition
                textWriter.WriteStartElement("Object");
                textWriter.WriteStartAttribute("Type");
                textWriter.WriteValue(mogRoot.ProjectOptions.SceneManagerName);
                textWriter.WriteEndAttribute();
                textWriter.WriteStartAttribute("SceneManagerType");
                textWriter.WriteValue(mogRoot.ProjectOptions.SceneManagerName);
                textWriter.WriteEndAttribute();
                textWriter.WriteStartAttribute("Name");
                textWriter.WriteValue("SceneManager");
                textWriter.WriteEndAttribute();
                textWriter.WriteStartAttribute("Ambient");
                textWriter.WriteValue("1.000 1.000 1.000");
                textWriter.WriteEndAttribute();
                textWriter.WriteEndElement();

                textWriter.WriteEndElement();
                textWriter.WriteEndDocument();
                textWriter.Close();

                mogRoot.LoadScene(fileName);
            }

            this.statusString.Text = "New scene created";
        }
开发者ID:andyhebear,项目名称:likeleon,代码行数:58,代码来源:MainWindowCommands.cs


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