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


C# XmlTextWriter.WriteProcessingInstruction方法代码示例

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


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

示例1: Serialize

 public override void Serialize(XmlTextWriter xtw)
 {            
     xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
     xtw.WriteStartElement("xCal", "iCalendar", "urn:ietf:params:xml:ns:xcal");
     base.Serialize(xtw);
     xtw.WriteEndElement();
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:7,代码来源:xCalSerializer.cs

示例2: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/opensearchdescription+xml";

            using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, System.Text.Encoding.UTF8))
            {
                //get the details from host object
                Host host = HostCache.GetHost(HostHelper.GetHostAndPort(context.Request.Url));

                writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                writer.WriteStartElement("OpenSearchDescription", "http://a9.com/-/spec/opensearch/1.1/");
                writer.WriteElementString("ShortName", host.SiteTitle);
                writer.WriteElementString("Description", host.SiteDescription);
                writer.WriteElementString("Contact", host.Email);

                writer.WriteStartElement("Image");
                writer.WriteAttributeString("height", "16");
                writer.WriteAttributeString("weight", "16");
                writer.WriteAttributeString("type", "image/x-icon");
                writer.WriteString(string.Format("{0}/favicon.ico", host.RootUrl));
                writer.WriteEndElement();

                writer.WriteStartElement("Url");
                writer.WriteAttributeString("type", "text/html");
                writer.WriteAttributeString("method", "GET");
                writer.WriteAttributeString("template", string.Format("{0}/search?q={{searchTerms}}&user=False&page={{startPage?}}", host.RootUrl));
                writer.WriteEndElement();

                writer.Flush();
            }
        }
开发者ID:Letractively,项目名称:dotnetkicks,代码行数:32,代码来源:Search.ashx.cs

示例3: SimpleDumper

        static public bool SimpleDumper(string XMLFileName, Type type)
        {
            using (XmlTextWriter writer = new XmlTextWriter(XMLFileName, null))
            {
                Type[] types = { typeof(EffectInstanceDice) };// asm.GetTypes().Where(entry => entry.Namespace != null && entry.GetConstructor(System.Type.EmptyTypes) != null && entry.Namespace.StartsWith("BiM.Protocol.Data")).ToArray<Type>();
                try
                {
                    writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"");

                    XmlSerializer d2oSerializer = new XmlSerializer(type, types);
                    writer.WriteStartElement(type.Name + "_root");
                    // write
                    //using (var stream = File.Create(XMLFileName))
                    {
                        foreach (object obj in ObjectDataManager.Instance.EnumerateObjects(type))
                        {
                            d2oSerializer.Serialize(writer, obj); // your instance
                        }
                    }
                    writer.WriteEndElement();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

            }
            // Open a file for reading
            cleanXML(XMLFileName, false);
            return true;
        }
开发者ID:Ryuuke,项目名称:BehaviorIsManaged,代码行数:31,代码来源:XmlDumper.cs

示例4: GlobalXMLManipulatorWriter

 public GlobalXMLManipulatorWriter(string fileName, bool scrabled)
     : base(null)
 {
     try
     {
         if (scrabled)
         {
             Exception exception = new Exception("Incorrect file!");
             throw exception;
         }
         this._xmlDoc = new XmlDocument();
         this._fileName = fileName;
         XmlTextWriter writer = new XmlTextWriter(this._fileName, Encoding.UTF8) {
             Formatting = Formatting.Indented
         };
         writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         writer.Close();
         this._xmlDoc.Load(this._fileName);
         XmlNode documentElement = this._xmlDoc.DocumentElement;
         base._parentNode = base._iteratorNode = (XmlElement) documentElement;
         if (base._parentNode != null)
         {
             base.isInitialized = true;
         }
     }
     catch (Exception exception2)
     {
         GlobalXMLManipulator._log.Error("Invalid File to load! GlobalXMLManipulatorWriter()\n" + exception2.Message);
     }
 }
开发者ID:x893,项目名称:WDS,代码行数:30,代码来源:GlobalXMLManipulatorWriter.cs

示例5: SaveSettings

		public override void SaveSettings()
		{
            if (!this.writeable)
                throw new InvalidOperationException("Attempted to write to a non-writeable Settings Storage");

			string dirPath = Path.GetDirectoryName( filePath );
			if ( !Directory.Exists( dirPath ) )
				Directory.CreateDirectory( dirPath );

			XmlTextWriter writer = new XmlTextWriter(  filePath, System.Text.Encoding.UTF8 );
			writer.Formatting = Formatting.Indented;

			writer.WriteProcessingInstruction( "xml", "version=\"1.0\"" );
			writer.WriteStartElement( "NUnitSettings" );
			writer.WriteStartElement( "Settings" );

			ArrayList keys = new ArrayList( settings.Keys );
			keys.Sort();

			foreach( string name in keys )
			{
				object val = settings[name];
				if ( val != null )
				{
					writer.WriteStartElement( "Setting");
					writer.WriteAttributeString( "name", name );
					writer.WriteAttributeString( "value", val.ToString() );
					writer.WriteEndElement();
				}
			}

			writer.WriteEndElement();
			writer.WriteEndElement();
			writer.Close();
		}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:35,代码来源:XmlSettingsStorage.cs

示例6: ToString

        public override string ToString()
        {
            string doc;

            using (var sw = new StringWriter()) {
                using (var writer = new XmlTextWriter(sw)) {
                    writer.Formatting = Formatting.Indented;
                    //writer.WriteStartDocument();
                    writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                    writer.WriteStartElement("D", "multistatus", "DAV:");
                    for (int i = 0; i < _nameSpaceList.Count; i++) {
                        string tag = string.Format("ns{0}", i);
                        writer.WriteAttributeString("xmlns", tag, null, _nameSpaceList[i]);
                    }

                    foreach (var oneResponse in _ar) {
                        oneResponse.Xml(writer);
                    }
                    writer.WriteEndElement();
                    //writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                    doc = sw.ToString();
                    writer.Flush();
                    writer.Close();
                }
                sw.Flush();
                sw.Close();
            }
            return doc;
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:31,代码来源:PropFindResponce.cs

示例7: Serialize

        public override string Serialize(Node node, Type typeAttr)
        {
            XpcaProxy proxy = new XpcaProxy(node);
            StringWriter sw = new StringWriter();

            using(XmlWriter xmlWriter = new XmlTextWriter(sw))
            {
                xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
                xmlWriter.WriteStartElement("root");
                foreach (KeyValuePair<string, PropertyInfo> property in proxy.GetPropertiesFor(typeAttr)) {

                    object value = proxy[property.Key];
                    if (value != null) {
                        xmlWriter.WriteStartElement(property.Key);
                        if(value is IEnumerable<object>) {
                            foreach (object obj in (value as IEnumerable<object>)) {
                                xmlWriter.WriteStartElement("item");
                                XmlWriteValue(xmlWriter, obj);
                                xmlWriter.WriteEndElement();
                            }

                        }
                        else {
                            XmlWriteValue(xmlWriter, value);
                        }
                        xmlWriter.WriteEndElement();
                    }
                }
                xmlWriter.WriteEndElement();
            }

            return sw.ToString();
        }
开发者ID:flipback,项目名称:Galilei,代码行数:33,代码来源:XmlSerializer.cs

示例8: XmlWriter

        public XmlWriter()
        {
            string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"/Table1.xml";

            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(filename);
            }
            catch (System.IO.FileNotFoundException ex)
            {
                Console.WriteLine(ex);
                XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteStartElement("Table");
                xmlWriter.WriteStartElement("Players");
                xmlWriter.WriteEndElement();
                xmlWriter.WriteStartElement("Dealer");
                xmlWriter.WriteStartElement("DealerCards");
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
                xmlWriter.Close();
                xmlDoc.Load(filename);
            }
        }
开发者ID:no1spirite,项目名称:BlackJack,代码行数:27,代码来源:XmlWriter.cs

示例9: writeOptions

 public void writeOptions()
 {
     Directory.CreateDirectory(OPTIONS_PATH);
     XmlDocument xmlDoc = new XmlDocument();
     try
     {
         xmlDoc.Load(OPTIONS_FILE);
     }
     catch (System.IO.FileNotFoundException)
     {
         //if file is not found, create a new xml file
         XmlTextWriter xmlWriter = new XmlTextWriter(OPTIONS_FILE, System.Text.Encoding.UTF8);
         xmlWriter.Formatting = Formatting.Indented;
         xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         xmlWriter.WriteStartElement("root");
         //If WriteProcessingInstruction is used as above,
         //Do not use WriteEndElement() here
         //xmlWriter.WriteEndElement();
         //it will cause the <Root> to be &ltRoot />
         xmlWriter.Close();
         xmlDoc.Load(OPTIONS_FILE);
     }
     XmlNode root = xmlDoc.DocumentElement;
     root.AppendChild(asXML(root));
     xmlDoc.Save(OPTIONS_FILE);
 }
开发者ID:narfman0,项目名称:BountyBanditsWorldEditor,代码行数:26,代码来源:Options.cs

示例10: GetStatesXMLString

		/// <summary>
		/// This function retuns list of states for a given country as XML Document in a string 
		/// and this value is used in client side java script to populate state combo box.
		/// Functionality: Transform the CountriesAndStates xml string into another XML string having the single country 
		/// and states under that country. 
		/// </summary>
		public string GetStatesXMLString(string countryName)
		{
			//Creates a XslTransform object and load the CountriesAndStates.xsl file
			XslTransform transformToCountryNode = new XslTransform();
			transformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver());
			//TransformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence);

			//Creating the XSLT parameter country-name and setting the value
			XsltArgumentList xslArgs = new XsltArgumentList();
			xslArgs.AddParam("country-name", "", countryName);
				
			// Memory stream to store the result of XSL transform 
			MemoryStream countryNodeMemoryStream = new MemoryStream(); 
			XmlTextWriter countryNodeXmlTextWriter = new XmlTextWriter(countryNodeMemoryStream, Encoding.UTF8); 
			countryNodeXmlTextWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

			//transforming the current XML string to get the state XML string
			transformToCountryNode.Transform(xPathDoc, xslArgs,  countryNodeXmlTextWriter);
			//TransformToCountryNode.Transform(XPathDoc, XslArgs,  CountryNodeXmlTextWriter, null);

			//reading the XML string using StreamReader and return the same
			countryNodeXmlTextWriter.Flush(); 
			countryNodeMemoryStream.Position = 0; 
			StreamReader countryNodeStreamReader = new StreamReader(countryNodeMemoryStream); 
			return  countryNodeStreamReader.ReadToEnd(); 
		}
开发者ID:TestRvSlv,项目名称:reporting,代码行数:32,代码来源:CountryStateXml.cs

示例11: XmlFile

        public XmlFile(FileInfo file, bool create, string root_name) {
            this.File = file;
            file.Refresh();
            if (!file.Exists) {
				if(create) {
                	XmlTextWriter write_here = new XmlTextWriter(file.FullName, System.Text.Encoding.UTF8);
                	write_here.Formatting = Formatting.Indented;
                	write_here.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
					//write_here.WriteStartElement(root_name);
					//write_here.WriteEndElement();
					write_here.Close();
				} else {
					throw new FileNotFoundException("XMl file not found",file.FullName);
				}
            }
            XmlReader parse_me = XmlReader.Create(file.FullName, xml_settings);
            try {
                this.Load(parse_me);
            } catch (Exception ex) {
                IXmlLineInfo info = parse_me as IXmlLineInfo;
                throw new XmlException(file.FullName + Environment.NewLine + Environment.NewLine + "Line: " + info.LineNumber + " Column: " + info.LinePosition, ex);
            } finally {
                parse_me.Close();
            }
        }
开发者ID:sanmadjack,项目名称:XmlData.CSharp,代码行数:25,代码来源:XmlFile.cs

示例12: Save

		public void Save (System.IO.Stream stream)
		{
			try {
				XmlTextWriter text;
				RdfXmlWriter writer;
                                XmlDocument rdfdoc = new XmlDocument();

                                // first, construct the rdf guts, semweb style
                                writer = new XmpWriter (rdfdoc);
				//writer.Namespaces.Parent = MetadataStore.Namespaces;
				writer.Write (store);
				writer.Close ();
			       
                                // now construct the xmp wrapper packet
				text = new XmlTextWriter (stream, System.Text.Encoding.UTF8);
 				text.Formatting = Formatting.Indented;
                        
                                text.WriteProcessingInstruction ("xpacket", "begin=\"\ufeff\" id=\"W5M0MpCehiHzreSzNTczkc9d\"");
                                text.WriteStartElement ("x:xmpmeta");
                                text.WriteAttributeString ("xmlns", "x", null, "adobe:ns:meta/");

				((XmlElement)rdfdoc.ChildNodes[1]).RemoveAttribute ("xml:base");
				rdfdoc.ChildNodes[1].WriteTo (text);

                                // now close off the xmp packet
                                text.WriteEndElement ();
                                text.WriteProcessingInstruction ("xpacket", "end=\"r\"");
				text.Close ();
				
			} catch (System.Exception e) {
				//System.Console.WriteLine (e);
			}
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:33,代码来源:XmpFile.cs

示例13: WriteHeader

        /// <summary>
        /// 
        /// </summary>
        protected override void WriteHeader()
        {
            writer = base.GetXmlTextWriter();
            writer.Formatting = Formatting.Indented;

            writer.WriteProcessingInstruction("xml", "version=\"1.0\"");
            writer.WriteProcessingInstruction("zpl", "version=\"1.0\"");
            writer.WriteStartElement("smil");

            writer.WriteStartElement("head");
            writer.WriteElementString("title", base.name + " Playlist");
            writer.WriteElementString("generator", App.NameVersion);
            writer.WriteEndElement(); // head

            writer.WriteStartElement("body");
            writer.WriteStartElement("seq");
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:20,代码来源:ZPLPlaylistWriter.cs

示例14: createConfig

 protected override bool createConfig(string file_name) {
     XmlTextWriter write_here = new XmlTextWriter(file_name, System.Text.Encoding.UTF8);
     write_here.Formatting = Formatting.Indented;
     write_here.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
     write_here.WriteStartElement("settings");
     write_here.Close();
     return true;
 }
开发者ID:sanmadjack,项目名称:Config.CSharp,代码行数:8,代码来源:XmlSettingsFile.cs

示例15: OnNext

 protected internal override bool OnNext()
 {
     string text = this._fileNameTextBox.Text;
     if (text.Length == 0)
     {
         MessageBox.Show(base.WizardForm, "You must specify a filename", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     if (text.IndexOfAny(Path.InvalidPathChars) != -1)
     {
         MessageBox.Show(base.WizardForm, "The specified filename contains invalid characters.", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     ListSnippetsWizardPanel snippetList = ((ExportSnippetsWizard) base.WizardForm).SnippetList;
     FileStream stream = null;
     bool flag = false;
     try
     {
         if (Path.GetExtension(text).Length == 0)
         {
             text = text + ".snippets";
         }
         stream = new FileStream(text, FileMode.Create, FileAccess.Write, FileShare.Write);
         XmlTextWriter writer = new XmlTextWriter(new StreamWriter(stream, Encoding.UTF8));
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.IndentChar = ' ';
         writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         writer.WriteStartElement("Snippets");
         foreach (SnippetToolboxDataItem item in snippetList.CheckedToolboxDataItems)
         {
             writer.WriteStartElement("Snippet");
             if (item.InternalDisplayName.Length > 0)
             {
                 writer.WriteAttributeString("name", item.InternalDisplayName);
             }
             writer.WriteString(item.ToolboxData);
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
         writer.Flush();
         writer.Close();
     }
     catch
     {
         MessageBox.Show(base.WizardForm, "The specified file could not be written.", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         flag = true;
     }
     finally
     {
         if (stream != null)
         {
             stream.Close();
         }
     }
     return !flag;
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:57,代码来源:SaveSnippetsWizardPanel.cs


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