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


C# XmlTextWriter.Flush方法代码示例

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


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

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

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

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("urlset");
        writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

        string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
        if (!Request.Url.IsDefaultPort)
        {
            siteUrl += ":" + Request.Url.Port;
        }
        Menu menu = new Menu();
        Utils.InitMenu(menu, false, false, false);
        foreach (MenuItem item in menu.Items)
        {
            writer.WriteStartElement("url");
            writer.WriteElementString("loc", siteUrl + item.NavigateUrl);
            writer.WriteEndElement();
            foreach (MenuItem childItem in item.ChildItems)
            {
                writer.WriteStartElement("url");
                writer.WriteElementString("loc", siteUrl + childItem.NavigateUrl);
                writer.WriteEndElement();
            }
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        Response.End();
    }
开发者ID:ivladyka,项目名称:Ekran,代码行数:33,代码来源:SiteMap.aspx.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        Response.ContentType = "application/xml";
        DataTable dt = CreateBll.GetInfo(TABLE_NAME, 1, 100);

        MemoryStream ms = new MemoryStream();
        XmlTextWriter xmlTW = new XmlTextWriter(ms, Encoding.UTF8);
        xmlTW.Formatting = Formatting.Indented;
        xmlTW.WriteStartDocument();
        xmlTW.WriteStartElement("urlset");
        xmlTW.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
        xmlTW.WriteAttributeString("xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9");

        foreach (DataRow dr in dt.Rows)
        {
            xmlTW.WriteStartElement("url");
            string infoUrl = CreateBll.GetInfoUrl(dr,1).ToLower();
            if(!infoUrl.StartsWith("http://")&&!infoUrl.StartsWith("https://")&&!infoUrl.StartsWith("ftp://"))
            {
                if(Param.ApplicationRootPath==string.Empty)
                {
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
                else
                {
                    infoUrl = infoUrl.Replace(Param.ApplicationRootPath.ToLower(),string.Empty);
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
            }
            xmlTW.WriteElementString("loc", infoUrl);

            xmlTW.WriteStartElement("news:news");
            xmlTW.WriteElementString("news:publication_date", dr["addtime"].ToString());
             string keywords = dr["tagnamestr"].ToString();
            if (keywords.StartsWith("|") && keywords.EndsWith("|"))
            {
                keywords = keywords.Substring(0, keywords.Length - 1);
                keywords = keywords.Substring(1, keywords.Length - 1);
                keywords = keywords.Replace("|",",");
            }
            xmlTW.WriteElementString("news:keywords", keywords);
            xmlTW.WriteEndElement();
            xmlTW.WriteEndElement();
        }
        xmlTW.WriteEndDocument();
        xmlTW.Flush();
        byte[] buffer = ms.ToArray();
        Response.Write(Encoding.UTF8.GetString(buffer));
        Response.End();
        xmlTW.Close();
        ms.Close();
        ms.Dispose();
    }
开发者ID:suizhikuo,项目名称:KYCMS,代码行数:54,代码来源:GoogleSiteMap.aspx.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     doxml.Service ser = new Service();
     XmlNode xml = ser.sendXml();
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.ContentType = "text/xml";
     HttpContext.Current.Response.Charset = "UTF-8 ";
     XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, System.Text.Encoding.UTF8);
     writer.Formatting = Formatting.Indented;
     xml.WriteTo(writer);
     writer.Flush();
     HttpContext.Current.Response.End();
 }
开发者ID:vinStar,项目名称:vin_zone_2009,代码行数:13,代码来源:showXML.aspx.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate Action Stored Procedure object
        Blogic FetchData = new Blogic();

        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        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", "Ex-designz.net Most Popular Recipe RSS Feed");
        objX.WriteElementString("link", "http://www.myasp-net.com");
        objX.WriteElementString("description", "Recipe database from around the world");
        objX.WriteElementString("copyright", "(c) 2005, Myasp-net.com and Ex-designz.net. All rights reserved.");
        objX.WriteElementString("ttl", "10");

        //Get datatable
        IDataReader dr = FetchData.GetRSSMostPopularRecipe;

        //loop through all record, and write XML for each item.
        for (i = 0; i <= 20 - 1; i++)
        {
            dr.Read();
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Name"].ToString());
            objX.WriteElementString("link", "http://www.ex-designz.net/recipedisplay.asp?rid=" + (int)dr["ID"]);
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["Date"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();

        FetchData = null;
    }
开发者ID:dineshkummarc,项目名称:WorldRecipe-CS,代码行数:49,代码来源:toprecipexml.aspx.cs

示例7: Main

 public static void Main() {
 StringWriter w = new StringWriter();
 XmlTextWriter x = new XmlTextWriter(w);
 x.Formatting = Formatting.Indented;
 x.WriteStartDocument();
 x.WriteComment("a simple test");
 x.WriteStartElement("message");
 x.WriteStartAttribute("project", "");
 x.WriteString("Rotor");
 x.WriteEndAttribute();
 x.WriteString("Hello world!");
 x.WriteEndElement();
 x.WriteEndDocument();
 x.Flush();
 Console.WriteLine(w.ToString());
 }
开发者ID:ArildF,项目名称:masters,代码行数:16,代码来源:helloxml.cs

示例8: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        XmlDocument xml = new XmlDocument();
        DataTable dt = CreateDataSource();
        DataSet ds = new DataSet("testDS");
        ds.Tables.Add(dt);
        xml.LoadXml(ds.GetXml());

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "text/xml ";
        HttpContext.Current.Response.Charset = "UTF-8 ";
        XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, System.Text.Encoding.UTF8);
        writer.Formatting = Formatting.Indented;
        xml.WriteTo(writer);
        writer.Flush();
        HttpContext.Current.Response.End();
    }
开发者ID:vinStar,项目名称:vin_zone_2009,代码行数:17,代码来源:showXML.aspx.cs

示例9: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        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", "VGuitar.net những bài hát yêu thích nhất RRS");
        objX.WriteElementString("link", "http://thlb.biz");
        objX.WriteElementString("description", "Lyric database from around the world");
        objX.WriteElementString("copyright", "(c) 2009, thlb.biz");
        objX.WriteElementString("ttl", "10");

        //Get datatable
        IDataReader dr = Blogic.ActionProcedureDataProvider.GetRSSMostPopularLyric;

        //loop through all record, and write XML for each item.
        for (i = 0; i <= 20 - 1; i++)
        {
            dr.Read();
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Name"].ToString());
            objX.WriteElementString("link", "http://thlb.biz?rid=" + (int)dr["ID"]);
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["Date"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();
    }
开发者ID:mangmaytinh,项目名称:vguitar,代码行数:44,代码来源:toplyricxml.aspx.cs

示例10: DeleteByKey

 /// <summary>
 /// 删除[appSettings]节点中包含Key值的子节点,返回成功与否布尔值
 /// </summary>
 /// <param name="configurationFile">要操作的配置文件名称,枚举常量</param>
 /// <param name="key">要删除的子节点Key值</param>
 /// <returns>返回成功与否布尔值</returns>
 public static bool DeleteByKey(ConfigurationFile configurationFile, string key)
 {
     bool isSuccess = false;
     string filename = string.Empty;
     if (configurationFile.ToString() == ConfigurationFile.AppConfig.ToString())
     {
         filename = System.Windows.Forms.Application.ExecutablePath + ".config";
     }
     else
     {
         filename = System.AppDomain.CurrentDomain.BaseDirectory + "web.config";
     }
     XmlDocument doc = new XmlDocument();
     doc.Load(filename); //加载配置文件
     XmlNode node = doc.SelectSingleNode("//appSettings");   //得到[appSettings]节点
     ////得到[appSettings]节点中关于Key的子节点
     XmlElement element = (XmlElement)node.SelectSingleNode("//add[@key='" + key + "']");
     if (element != null)
     {
         //存在则删除子节点
         element.ParentNode.RemoveChild(element);
     }
     else
     {
         //不存在
     }
     try
     {
         //保存至配置文件(方式一)
         using (XmlTextWriter xmlwriter = new XmlTextWriter(filename, null))
         {
             xmlwriter.Formatting = Formatting.Indented;
             doc.WriteTo(xmlwriter);
             xmlwriter.Flush();
         }
         isSuccess = true;
     }
     catch (Exception ex)
     {
         isSuccess = false;
     }
     return isSuccess;
 }
开发者ID:hj-nicholas,项目名称:BaseFrame,代码行数:49,代码来源:ConfigHelper.cs

示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("urlset");
        writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

        VikkiSoft_BLL.Country cont = new VikkiSoft_BLL.Country();
        if (cont.LoadSiteMap())
        {
            string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
            if (!Request.Url.IsDefaultPort)
            {
                siteUrl += ":" + Request.Url.Port;
            }
            siteUrl += "/";
            AddURL(writer, siteUrl, "Default.aspx", cont.DateUpdate);
            AddURL(writer, siteUrl, "Blogs.aspx", cont.DateUpdate);
            do
            {
                string url = "";
                if (cont.GetColumn("BlogPageID").ToString() != "0")
                {
                    url = Utils.GenerateFriendlyURL("page", new string[] { cont.GetColumn("BlogPageID").ToString(), cont.GetColumn("BlogPageName_en").ToString() }, false);
                }
                else if(cont.GetColumn("CityName").ToString() == "")
                {
                    url = Utils.GenerateFriendlyURL("country", new string[] { cont.GetColumn("CountryName").ToString() }, false);
                }
                else{
                    url = Utils.GenerateFriendlyURL("city", new string[] { cont.GetColumn("CountryName").ToString(), cont.GetColumn("CityName").ToString() }, false);
                }
                AddURL(writer, siteUrl, url, cont.DateUpdate);
            } while (cont.MoveNext());
        }

        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        Response.End();
    }
开发者ID:ivladyka,项目名称:OurTravels,代码行数:43,代码来源:SiteMap.aspx.cs

示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        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", "ExamCrazy.com Newest RSS Feed");
        objX.WriteElementString("link", "http://www.examcrazy.com");
        objX.WriteElementString("description", "ExamCrazy.Com RSS");
        objX.WriteElementString("copyright", "(c) 2005, ExamCrazy.Com. All rights reserved.");
        objX.WriteElementString("ttl", "10");

        //Get data
        IDataReader dr = Blogic.ActionProcedureDataProvider.GetRssNewFeed;

        //loop through all record, and write XML for each item.
        for (i = 0; (i <= 20 - 1) && (dr.Read() == true); i++)
        {
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Title"].ToString());
            objX.WriteElementString("link", dr["Title"].ToString());
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["DatePublished"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();
    }
开发者ID:ranukhandelwal,项目名称:EC,代码行数:43,代码来源:newrssxml.aspx.cs

示例13: PrettyPrint

        public static string PrettyPrint(string xml)
        {
            string Result = "";

            MemoryStream MS = new MemoryStream();
            XmlTextWriter W = new XmlTextWriter(MS, Encoding.Unicode);
            XmlDocument D = new XmlDocument();

            try {
                // Load the XmlDocument with the XML.
                D.LoadXml(XML);

                W.Formatting = Formatting.Indented;

                // Write the XML into a formatting XmlTextWriter
                D.WriteContentTo(W);
                W.Flush();
                MS.Flush();

                // Have to rewind the MemoryStream in order to read
                // its contents.
                MS.Position = 0;

                // Read MemoryStream contents into a StreamReader.
                StreamReader SR = new StreamReader(MS);

                // Extract the text from the StreamReader.
                string FormattedXML = SR.ReadToEnd();

                Result = FormattedXML;
            }
            catch (XmlException) {
            }

            MS.Close();
            W.Close();

            return Result;
        }
开发者ID:pombredanne,项目名称:tools-12,代码行数:39,代码来源:XMLPrettyPrint.cs

示例14: HasMembers

 private static bool HasMembers(object obj)
 {
     if (obj is IXmlSerializable)
     {
         using (System.IO.MemoryStream mem = new System.IO.MemoryStream())
         {
             using (XmlTextWriter tw = new XmlTextWriter(mem, Encoding.UTF8))
             {
                 ((IXmlSerializable)obj).WriteXml(tw);
                 tw.Flush();
                 return mem.Length > 0;
             }
         }
     }
     else
     {
         // Enumerate each public property
         PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
         foreach (var pi in props)
         {
             if (!Attribute.IsDefined(pi, typeof(XmlIgnoreAttribute), false))
             {
                 object value = pi.GetValue(obj, null);
                 if (!value.Equals(GetDefaultValue(pi)))
                 {
                     if (!IsStandardType(pi.PropertyType))
                     {
                         if (HasMembers(value))
                             return true;
                     }
                     else
                         return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:BclEx,项目名称:BclEx-Extend,代码行数:38,代码来源:XmlSerializationHelper.cs

示例15: SaveDisplaySettings

        public void SaveDisplaySettings(string renderSystem, string resolution, string fullScreen)
        {
            XmlTextWriter settingsWriter = new XmlTextWriter("DisplayConfig.xml", null);
            settingsWriter.Formatting = Formatting.Indented;
            settingsWriter.Indentation = 6;
            settingsWriter.Namespaces = false;

            settingsWriter.WriteStartDocument();
            settingsWriter.WriteStartElement("", "Settings", "");
            settingsWriter.WriteStartElement("", "RenderSystem", "");
            settingsWriter.WriteString(renderSystem);
            settingsWriter.WriteEndElement();

            settingsWriter.WriteStartElement("", "Resolution", "");
            settingsWriter.WriteString(resolution);
            settingsWriter.WriteEndElement();

            settingsWriter.WriteStartElement("", "FullScreen", "");
            settingsWriter.WriteString(fullScreen);
            settingsWriter.WriteEndElement();
            settingsWriter.WriteEndElement();
            settingsWriter.WriteEndDocument();
            settingsWriter.Flush();
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:24,代码来源:ConfigDisplay.cs


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