本文整理汇总了C#中XmlTextWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.Close方法的具体用法?C# XmlTextWriter.Close怎么用?C# XmlTextWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnLahetaPalaute_Click
protected void btnLahetaPalaute_Click(object sender, EventArgs e)
{
string filename = MapPath("~/App_Data/Palautteet.xml");
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlElement newElem = doc.CreateElement("palaute");
newElem.InnerXml = "<pvm>" + this.tbxPvm.Text + "</pvm>" +
"<tekija>" + this.tbxNimi.Text + "</tekija>" +
"<opittu>" + this.tbxOlenOppinut.Text + "</opittu>" +
"<haluanoppia>" + this.tbxHaluanOppia.Text + "</haluanoppia>" +
"<hyvaa>" + this.tbxHyvaa.Text + "</hyvaa>" +
"<parannettavaa>" + this.tbxHuonoa.Text + "</parannettavaa>" +
"<muuta>" + this.tbxMuuta.Text + "</muuta>";
doc.DocumentElement.SelectNodes("/palautteet")[0].AppendChild(newElem);
XmlWriter w = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
doc.WriteTo(w);
w.Close();
this.tbxPvm.Text = "";
this.tbxNimi.Text = "";
this.tbxOlenOppinut.Text = "";
this.tbxHaluanOppia.Text = "";
this.tbxHyvaa.Text = "";
this.tbxHuonoa.Text = "";
this.tbxMuuta.Text = "";
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
MediaEntries entries = (MediaEntries) Cache.Get(cacheKey);
if (entries == null)
{
entries = MediaEntries.FromBlogKeyword("Piratpartiet", now.AddDays(-7));
Cache.Insert(cacheKey, entries, null, DateTime.UtcNow.AddMinutes (5) , System.Web.Caching.Cache.NoSlidingExpiration); // five minute cache is plenty to prevent db F5 attacks
}
Response.ContentType = "text/xml";
XmlWriter xml = new XmlTextWriter(Response.Output);
RssWriter rss = new RssWriter(xml);
rss.WriteHeader("Bloggat om Piratpartiet", "http://www.piratpartiet.se", "Bloggposter som nämner Piratpartiet", null);
foreach (MediaEntry entry in entries)
{
string title = entry.Title;
if (title.Length > 30)
{
title = title.Substring(0, 27) + "...";
}
rss.WriteItem(title, string.Empty, new Uri (entry.Url), entry.DateTime);
}
rss.Close();
xml.Close();
}
示例3: 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();
}
示例4: Action
public void Action() {
string xml = "<?xml version=\"1.0\"?>\n<a><b c=\"d\">e</b></a>";
string xsl = "<?xml version=\"1.0\"?>\n" +
"<xsl:stylesheet version=\"1.0\" " +
"xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" " +
"xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" " +
"xmlns:js=\"urn:js\" " +
">" +
"<msxsl:script language=\"jsCrIpt\" implements-prefix=\"js\">" +
"function SimpleTest() { return \"JScript test\"; }" +
"</msxsl:script>" +
"<xsl:template match=\"a\"><foo><xsl:apply-templates/></foo></xsl:template>" +
"<xsl:template match=\"b\"><xsl:element name=\"bar\">" +
"<xsl:attribute name=\"simpleTest\"><xsl:value-of select=\"js:SimpleTest()\"/></xsl:attribute>" +
"</xsl:element></xsl:template>" +
"<xsl:template match=\"/\"><xsl:apply-templates/></xsl:template>" +
"</xsl:stylesheet>";
XPathDocument myXPathDocument = new XPathDocument(new XmlTextReader(new StringReader(xml)));
XslTransform myXslTransform = new XslTransform();
myXslTransform.Load(new XmlTextReader(new StringReader(xsl)));
StringWriter myStringWriter = new StringWriter();
XmlTextWriter myXmlWriter = new XmlTextWriter(myStringWriter);
myXmlWriter.Formatting = Formatting.Indented;
myXslTransform.Transform(myXPathDocument, null, myXmlWriter);
myXmlWriter.Close();
Console.WriteLine(myStringWriter.ToString());
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
Organization org = Organization.FromIdentity(Int32.Parse(Request.QueryString["OrganizationId"]));
ExternalActivities activities = ExternalActivities.ForOrganization(org);
activities.Sort(ExternalActivities.SortOrder.DateDescending);
Response.ContentType = "text/xml";
XmlWriter xml = new XmlTextWriter(Response.Output);
RssWriter rss = new RssWriter(xml);
rss.WriteHeader("Aktivism - " + org.Name, "http://www.piratpartiet.se", "Aktivism för Piratpartiet", null);
foreach (ExternalActivity activism in activities)
{
string title = "Aktivism i " + activism.Geography.Name;
if (title.Length > 60)
{
title = title.Substring(0, 57) + "...";
}
rss.WriteItem(title, "<img src=\"http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity.ToString() + "\" />", new Uri("http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity), activism.CreatedDateTime);
}
rss.Close();
xml.Close();
}
示例6: DumpArrayToXml
public void DumpArrayToXml ()
{
string metadata_filename = dir + Path.DirectorySeparatorChar + "album-data.xml";
XmlTextWriter writer = new XmlTextWriter (metadata_filename, Encoding.UTF8);
writer.WriteStartDocument (true);
writer.WriteStartElement ("album", "www.ximian.com");
writer.WriteAttributeString ("name", album_name);
writer.WriteAttributeString ("count", picture_count.ToString ());
for (int i = 0; i < picture_count; ++i) {
writer.WriteStartElement ("picture", "www.ximian.com");
writer.WriteElementString ("location", "www.ximian.com", picture_data [i].Location);
writer.WriteElementString ("title", "www.ximian.com", picture_data [i].Title);
writer.WriteElementString ("date", "www.ximian.com", picture_data [i].Date);
writer.WriteElementString ("keywords", "www.ximian.com", picture_data [i].Keywords);
writer.WriteElementString ("comments", "www.ximian.com", picture_data [i].Comments);
writer.WriteElementString ("index", "www.ximian.com", picture_data [i].Index.ToString ());
writer.WriteEndElement ();
}
writer.WriteEndElement ();
writer.WriteEndDocument ();
writer.Close ();
}
示例7: Main
static int Main(string[] args)
{
int result = 0;
if (args.Length == 0)
{
Console.WriteLine("USAGE: GenerateWsdl.exe [Assembly] [Type] [URL] [File]");
result = -1;;
}
else
{
try
{
Assembly assembly = Assembly.LoadFrom(args[0]);
Type type = assembly.GetType(args[1]);
ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();
reflector.Reflect(type, args[2]);
XmlTextWriter writer = new XmlTextWriter(args[3], Encoding.ASCII);
writer.Formatting = Formatting.Indented;
reflector.ServiceDescriptions[0].Write(writer);
writer.Close();
}
catch(Exception ex)
{
Console.Error.WriteLine(ex);
result = -1;
}
}
return result;
}
示例8: WriteRSSFile
protected void WriteRSSFile()
{
try
{
string fileName = links.RssFeedLink.Replace(@"~\", ""); ;
string filePath = HttpRuntime.AppDomainAppPath + fileName;
XmlWriter xml = new XmlTextWriter(new StreamWriter(filePath));
RssWriter rss = new RssWriter(xml);
List<Item> itemList = engine.LoadItemDB(ProcessingEngine.Sort.Hot);
rss.WriteHeader("getputs.com", "http://www.getputs.com", "All Your News Belong To Us!", null);
foreach (Item item in itemList)
{
rss.WriteItem(item);
}
rss.Close();
xml.Close();
}
catch (Exception ex)
{
if (log.isLoggingOn && log.isAppLoggingOn)
{
log.Log("Error in RssPage.aspx");
log.Log(ex);
}
}
}
示例9: Create
void Create()
{
XmlTextWriter writer = new XmlTextWriter ("todo.xml", System.Text.Encoding.UTF8);
writer.WriteStartDocument ();
writer.WriteStartElement ("tasks");
writer.WriteEndElement ();
writer.Close ();
}
示例10: Write
public static void Write()
{
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.WriteStartDocument();
writer.WriteElementString("Hello", "Xml");
writer.WriteEndDocument();
writer.Close();
}
示例11: dumpDataSetToXmlFile
private void dumpDataSetToXmlFile(DataSet ds)
{
XmlTextWriter xtw = new XmlTextWriter(txtDumpToFile.Text, null);
ds.WriteXml(xtw, XmlWriteMode.WriteSchema);
xtw.Close();
lblErrorMessage.Text = "Done!";
}
示例12: Create
/// <summary>
/// This method is used for creating a new employee information in XML file
/// </summary>
/// <param name="employee">employee object</param>
/// <returns>True - Success, False - Failure</returns>
public bool Create(BLAutot auto)
{
try
{
// Checking if the file exist
if (!File.Exists(strFileName))
{
// If file does not exist in the database path, create and store an empty Autot node
XmlTextWriter textWritter = new XmlTextWriter(strFileName, null);
textWritter.WriteStartDocument();
textWritter.WriteStartElement("Wanhatautot");
textWritter.WriteEndElement();
textWritter.Close();
}
// Create the XML document by loading the file
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(strFileName);
// Creating Auto node
XmlElement subNode = xmlDoc.CreateElement("Auto");
// Getting the maximum Id based on the XML data already stored
string strId = CommonMethods.GetMaxValue(xmlDoc, "Wanhatautot" + "/" + "Auto" + "/" + "aid").ToString();
// Adding Id column. Auto generated column
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "aid", strId));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "rekkari", auto.rekkari));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "merkki", auto.merkki));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "malli", auto.malli));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "vm", auto.vm.ToString()));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "myyntiHinta", auto.myyntiHinta.ToString()));
xmlDoc.DocumentElement.AppendChild(subNode);
subNode.AppendChild(CommonMethods.CreateXMLElement(xmlDoc, "sisaanOstoHinta", auto.sisaanOstoHinta.ToString()));
xmlDoc.DocumentElement.AppendChild(subNode);
// Saving the file after adding the new auto node
xmlDoc.Save(strFileName);
return true;
}
catch (Exception ex)
{
throw ex;
}
}
示例13: 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();
}
示例14: CreateXmlFile
public static void CreateXmlFile(string fileName, string rootElementName)
{
XmlTextWriter writer = new XmlTextWriter(fileName, System.Text.Encoding.UTF8);
writer.WriteStartDocument();
writer.Formatting = Formatting.Indented;
writer.Indentation = 2;
writer.WriteStartElement(rootElementName);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
示例15: Main
/// <summary>
/// The entry point for the application.
/// </summary>
/// <param name="args"> A list of command line arguments</param>
public static int Main(String[] args)
{
// TODO: Add code to start application here
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.WriteStartDocument();
writer.WriteElementString("Hello", "XML");
writer.WriteEndDocument();
writer.Close();
return 0;
}