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


C# XmlTextWriter.Flush方法代码示例

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


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

示例1: ParseHtml

        // Creates XmlDocument from html content and return it with rootitem "<root>".
        public static XmlDocument ParseHtml(string sContent)
        {
            StringReader sr = new StringReader("<root>" + sContent + "</root>");
            SgmlReader reader = new SgmlReader();
            reader.WhitespaceHandling = WhitespaceHandling.All;
            reader.CaseFolding = Sgml.CaseFolding.ToLower;
            reader.InputStream = sr;

            StringWriter sw = new StringWriter();
            XmlTextWriter w = new XmlTextWriter(sw);
            w.Formatting = Formatting.Indented;
            w.WriteStartDocument();
            reader.Read();
            while (!reader.EOF)
            {
                w.WriteNode(reader, true);
            }
            w.Flush();
            w.Close();

            sw.Flush();

            // create document
            XmlDocument doc = new XmlDocument();
            doc.PreserveWhitespace = true;
            doc.XmlResolver = null;
            doc.LoadXml(sw.ToString());

            reader.Close();

            return doc;
        }
开发者ID:Cabana,项目名称:CMSConverter,代码行数:33,代码来源:SgmlUtil.cs

示例2: SetValue

        /// <summary>
        /// Define o valor de uma configuração
        /// </summary>
        /// <param name="file">Caminho do arquivo (ex: c:\program.exe.config)</param>
        /// <param name="key">Nome da configuração</param>
        /// <param name="value">Valor a ser salvo</param>
        /// <returns></returns>
        public static bool SetValue(string file, string key, string value)
        {
            var fileDocument = new XmlDocument();
            fileDocument.Load(file);
            var nodes = fileDocument.GetElementsByTagName(AddElementName);

            if (nodes.Count == 0)
            {
                return false;
            }

            for (var i = 0; i < nodes.Count; i++)
            {
                var node = nodes.Item(i);
                if (node == null || node.Attributes == null || node.Attributes.GetNamedItem(KeyPropertyName) == null)
                    continue;
                
                if (node.Attributes.GetNamedItem(KeyPropertyName).Value == key)
                {
                    node.Attributes.GetNamedItem(ValuePropertyName).Value = value;
                }
            }

            var writer = new XmlTextWriter(file, null) { Formatting = Formatting.Indented };
            fileDocument.WriteTo(writer);
            writer.Flush();
            writer.Close();
            return true;
        }
开发者ID:webbers,项目名称:dongle.net,代码行数:36,代码来源:AppConfig.cs

示例3: SaveRegister

        private bool SaveRegister(string RegisterKey)
        {
            try
            {
                
                Encryption enc = new Encryption();
                FileStream fs = new FileStream("reqlkd.dll", FileMode.Create);
                XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

                // Khởi động tài liệu.
                w.WriteStartDocument();
                w.WriteStartElement("QLCV");

                // Ghi một product.
                w.WriteStartElement("Register");
                w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID));
                w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial));
                w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID));
                w.WriteEndElement();

                // Kết thúc tài liệu.
                w.WriteEndElement();
                w.WriteEndDocument();
                w.Flush();
                w.Close();
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
开发者ID:phinq19,项目名称:qlcongviec,代码行数:34,代码来源:frmRegister.cs

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

示例5: BuildAccessKey

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// builds XML access key for UPS requests
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[mmcconnell]	11/1/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static string BuildAccessKey(UpsSettings settings)
        {
            string sXML = "";
            StringWriter strWriter = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(strWriter);

            xw.Formatting = Formatting.Indented;
            xw.Indentation = 3;

            xw.WriteStartDocument();

            //--------------------------------------------            
            // Agreement Request
            xw.WriteStartElement("AccessRequest");

            xw.WriteElementString("AccessLicenseNumber", settings.License);
            xw.WriteElementString("UserId", settings.UserID);
            xw.WriteElementString("Password", settings.Password);

            xw.WriteEndElement();
            // End Agreement Request
            //--------------------------------------------

            xw.WriteEndDocument();
            xw.Flush();
            xw.Close();

            sXML = strWriter.GetStringBuilder().ToString();

            xw = null;

            //HttpContext.Current.Trace.Write("AccessRequest=" & sXML)

            return sXML;
        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:47,代码来源:XmlTools.cs

示例6: GenerateDescription

        private void GenerateDescription(string host = null)
        {
            MemoryStream memStream = new MemoryStream();
            using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false)))
            {
                descWriter.Formatting = Formatting.Indented;
                descWriter.WriteRaw("<?xml version=\"1.0\"?>");

                descWriter.WriteStartElement("root", "urn:schemas-upnp-org:device-1-0");

                descWriter.WriteStartElement("specVersion");
                descWriter.WriteElementString("major", "1");
                descWriter.WriteElementString("minor", "0");
                descWriter.WriteEndElement();

                descWriter.WriteStartElement("device");
                rootDevice.WriteDescription(descWriter, host);
                descWriter.WriteEndElement();

                descWriter.WriteEndElement();

                descWriter.Flush();
                descArray = memStream.ToArray();
            }
        }
开发者ID:northspb,项目名称:p2pproxy,代码行数:25,代码来源:UpnpServer.cs

示例7: Search

        public object Search(queryrequest xml)
        {
            SemWeb.Query.Query query = null;

            string q = string.Empty;

            try
            {
                query = new SparqlEngine(new StringReader(xml.query));
            }
            catch (QueryFormatException ex)
            {
                var malformed = new malformedquery();

                malformed.faultdetails = ex.Message;

                return malformed;
            }

            // Load the data from sql server
            SemWeb.Stores.SQLStore store;

            string connstr = ConfigurationManager.ConnectionStrings["SemWebDB"].ConnectionString;

            DebugLogging.Log(connstr);

            store = (SemWeb.Stores.SQLStore)SemWeb.Store.CreateForInput(connstr);

            //Create a Sink for the results to be writen once the query is run.
            MemoryStream ms = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.UTF8);
            QueryResultSink sink = new SparqlXmlQuerySink(writer);

            try
            {
                // Run the query.
                query.Run(store, sink);

            }
            catch (Exception ex)
            {
                // Run the query.
                query.Run(store, sink);
                DebugLogging.Log("Run the query a second time");
                DebugLogging.Log(ex.Message);

            }
            //flush the writer then  load the memory stream
            writer.Flush();
            ms.Seek(0, SeekOrigin.Begin);

            //Write the memory stream out to the response.
            ASCIIEncoding ascii = new ASCIIEncoding();
            DebugLogging.Log(ascii.GetString(ms.ToArray()).Replace("???", ""));
            writer.Close();

            DebugLogging.Log("End of Processing");

            return SerializeXML.DeserializeObject(ascii.GetString(ms.ToArray()).Replace("???", ""), typeof(sparql)) as sparql;
        }
开发者ID:shariqatariq,项目名称:profiles-rns,代码行数:60,代码来源:ProfilesSPARQLAPI.svc.cs

示例8: Index

        public ActionResult Index()
        {
            var doc = new XDocument(new XDeclaration("1.0", "utf-8", null));

            var indexElement = new XElement(SitemapXmlNamespace + "sitemapindex");

            foreach (var sitemapData in _sitemapRepository.GetAllSitemapData())
            {
                var sitemapElement = new XElement(
                    SitemapXmlNamespace + "sitemap",
                    new XElement(SitemapXmlNamespace + "loc", _sitemapRepository.GetSitemapUrl(sitemapData))
                );

                indexElement.Add(sitemapElement);
            }

            doc.Add(indexElement);

            Response.Filter = new GZipStream(Response.Filter, CompressionMode.Compress);
            Response.AppendHeader("Content-Encoding", "gzip");

            byte[] sitemapIndexData;

            using (var ms = new MemoryStream())
            {
                var xtw = new XmlTextWriter(ms, Encoding.UTF8);
                doc.Save(xtw);
                xtw.Flush();
                sitemapIndexData = ms.ToArray();
            }

            return new FileContentResult(sitemapIndexData, "text/xml");
        }
开发者ID:MEmanuelsson,项目名称:SEO.Sitemaps,代码行数:33,代码来源:GetaSitemapIndexController.cs

示例9: Serialize

 public static XmlDocument Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingAction action)
 {
   Stream stm = new MemoryStream();
   XmlTextWriter xtw = new XmlTextWriter(stm, Encoding.UTF8);
   xtw.Formatting = Formatting.Indented;
   xtw.Indentation = 2;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   stm.Position = 0;    
   TextReader trdr = new StreamReader(stm, new UTF8Encoding(), true, 4096);
   String s = trdr.ReadLine();
   while (s != null)
   {
     //Console.WriteLine(s);
     s = trdr.ReadLine();
   }            
   stm.Position = 0;    
   XmlDocument xdoc = new XmlDocument();
   xdoc.PreserveWhitespace = true;
   xdoc.Load(stm);
   return xdoc;
 }
开发者ID:sgh1986915,项目名称:vfos-scraper-c-,代码行数:29,代码来源:utils.cs

示例10: Open

        /// <summary>
        /// Opens this shelf view.
        /// </summary>
        public override void Open()
        {
            IApplicationComponentView componentView = (IApplicationComponentView)ViewFactory.CreateAssociatedView(_shelf.Component.GetType());
            componentView.SetComponent((IApplicationComponent)_shelf.Component);

        	XmlDocument restoreDocument;
        	if (DesktopViewSettings.Default.GetShelfState(_desktopView.DesktopWindowName, _shelf.Name, out restoreDocument))
			{
				using (MemoryStream memoryStream = new MemoryStream())
				{
					using (XmlTextWriter writer = new XmlTextWriter(memoryStream, Encoding.UTF8))
					{
						restoreDocument.WriteContentTo(writer);
						writer.Flush();
						memoryStream.Position = 0;

						_content = _desktopView.AddShelfView(this, (Control) componentView.GuiElement, _shelf.Title, _shelf.DisplayHint, memoryStream);

						writer.Close();
						memoryStream.Close();
					}
				}
			}
			else
			{
				_content = _desktopView.AddShelfView(this, (Control)componentView.GuiElement, _shelf.Title, _shelf.DisplayHint, null);
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:31,代码来源:ShelfView.cs

示例11: ImportXMLfile

        static void ImportXMLfile(int popMember)
        {
            string filename = "";

            filename = GlobalVar.jobName + GlobalVar.popIndex.ToString() + popMember.ToString();

            XmlTextWriter xml = null;

            xml = new XmlTextWriter(filename, null);

            xml.WriteStartDocument();
            xml.WriteStartElement("Features");
            xml.WriteWhitespace("\n");

            for (int i = 0; i < GlobalVar.featureCount; i++)
            {
                xml.WriteElementString("Index", i.ToString());
                xml.WriteElementString("Value", GlobalVar.features[i].ToString());
                xml.WriteWhitespace("\n  ");
            }

            xml.WriteEndElement();
            xml.WriteWhitespace("\n");

            xml.WriteEndDocument();

            //Write the XML to file and close the writer.
            xml.Flush();
            xml.Close();
        }
开发者ID:smccaula,项目名称:MidiEvolution,代码行数:30,代码来源:as_put.cs

示例12: Respond

    /// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
    /// <remarks>This method deserializes the XML-RPC request, invokes the 
    /// described method, serializes the response (or fault) and sends the XML-RPC response
    /// back as a valid HTTP page.
    /// </remarks>
    /// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
    public void Respond(SimpleHttpRequest httpReq)
      {
	XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
	XmlRpcResponse xmlRpcResp = new XmlRpcResponse();

	try
	  {
	    xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
	  }
	catch (XmlRpcException e)
	  {
	    xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
	  }
	catch (Exception e2)
	  {
	    xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR, 
			  XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
	  }

	if (Logger.Delegate != null)
	  Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);

	XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
	httpReq.Output.Flush();
	XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
	_serializer.Serialize(xml, xmlRpcResp);
	xml.Flush();
	httpReq.Output.Flush();
      }
开发者ID:chrbayer84,项目名称:SLAgentCSServer,代码行数:35,代码来源:XmlRpcResponder.cs

示例13: SerializeSection

        protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name,
            ConfigurationSaveMode saveMode)
        {
            if ((CurrentConfiguration != null) &&
                (CurrentConfiguration.TargetFramework != null) &&
                !ShouldSerializeSectionInTargetVersion(CurrentConfiguration.TargetFramework))
                return string.Empty;

            ValidateElement(this, null, true);

            ConfigurationElement tempElement = CreateElement(GetType());
            tempElement.Unmerge(this, parentElement, saveMode);

            StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture);
            XmlTextWriter writer = new XmlTextWriter(strWriter)
            {
                Formatting = Formatting.Indented,
                Indentation = 4,
                IndentChar = ' '
            };

            tempElement.DataToWriteInternal = saveMode != ConfigurationSaveMode.Minimal;

            if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
                _configRecord.SectionsStack.Push(this);

            tempElement.SerializeToXmlElement(writer, name);

            if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
                _configRecord.SectionsStack.Pop();

            writer.Flush();
            return strWriter.ToString();
        }
开发者ID:chcosta,项目名称:corefx,代码行数:34,代码来源:ConfigurationSection.cs

示例14: Write

		/// <summary>
		/// Executes the syndication result on the given context.
		/// </summary>
		/// <param name="context">The current context.</param>
		public virtual void Write(IStreamResponse response) {
			var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);
			var ui = new Client.Helpers.UIHelper();

			// Write headers
			response.ContentType = ContentType;
			response.ContentEncoding = Encoding.UTF8;

			var feed = new SyndicationFeed() { 
				Title = new TextSyndicationContent(Config.Site.Title),
				LastUpdatedTime = Posts.First().Published.Value,
				Description = new TextSyndicationContent(Config.Site.Description),
			};
			feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/"))));

			var items = new List<SyndicationItem>();
			foreach (var post in Posts) {
				var item = new SyndicationItem() { 
					Title = SyndicationContent.CreatePlaintextContent(post.Title),
					PublishDate = post.Published.Value,
					Summary = SyndicationContent.CreateHtmlContent(post.Body)
				};
				item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/" + post.Type.Slug + "/" + post.Slug))));
				items.Add(item);
			}
			feed.Items = items;

			var formatter = GetFormatter(feed);
			formatter.WriteTo(writer);

			writer.Flush();
			writer.Close();
		}
开发者ID:cdie,项目名称:Piranha.vNext,代码行数:37,代码来源:PostFeed.cs

示例15: GenerateXMLPayload

        // This function generates the XML request body
        // for the FolderSync request.
        protected override void GenerateXMLPayload()
        {
            // If WBXML was explicitly set, use that
            if (WbxmlBytes != null)
                return;

            // Otherwise, use the properties to build the XML and then WBXML encode it
            XmlDocument folderSyncXML = new XmlDocument();

            XmlDeclaration xmlDeclaration = folderSyncXML.CreateXmlDeclaration("1.0", "utf-8", null);
            folderSyncXML.InsertBefore(xmlDeclaration, null);

            XmlNode folderSyncNode = folderSyncXML.CreateElement(Xmlns.folderHierarchyXmlns, "FolderSync", Namespaces.folderHierarchyNamespace);
            folderSyncNode.Prefix = Xmlns.folderHierarchyXmlns;
            folderSyncXML.AppendChild(folderSyncNode);

            if (syncKey == "")
                syncKey = "0";

            XmlNode syncKeyNode = folderSyncXML.CreateElement(Xmlns.folderHierarchyXmlns, "SyncKey", Namespaces.folderHierarchyNamespace);
            syncKeyNode.Prefix = Xmlns.folderHierarchyXmlns;
            syncKeyNode.InnerText = syncKey;
            folderSyncNode.AppendChild(syncKeyNode);

            StringWriter sw = new StringWriter();
            XmlTextWriter xmlw = new XmlTextWriter(sw);
            xmlw.Formatting = Formatting.Indented;
            folderSyncXML.WriteTo(xmlw);
            xmlw.Flush();

            XmlString = sw.ToString();
        }
开发者ID:MishaKharaba,项目名称:ExchangeActiveSync,代码行数:34,代码来源:ASFolderSyncRequest.cs


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