本文整理汇总了C#中XmlTextWriter.WriteAttributeString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteAttributeString方法的具体用法?C# XmlTextWriter.WriteAttributeString怎么用?C# XmlTextWriter.WriteAttributeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteAttributeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static int Main(string[] args)
{
if (args.Length < 1) {
Console.Error.WriteLine("Usage: RunMorphoCli tagger_file");
return 1;
}
Console.Error.Write("Loading tagger: ");
Tagger tagger = Tagger.load(args[0]);
if (tagger == null) {
Console.Error.WriteLine("Cannot load tagger from file '{0}'", args[0]);
return 1;
}
Console.Error.WriteLine("done");
Forms forms = new Forms();
TaggedLemmas lemmas = new TaggedLemmas();
TokenRanges tokens = new TokenRanges();
Tokenizer tokenizer = tagger.newTokenizer();
if (tokenizer == null) {
Console.Error.WriteLine("No tokenizer is defined for the supplied model!");
return 1;
}
XmlTextWriter xmlOut = new XmlTextWriter(Console.Out);
for (bool not_eof = true; not_eof; ) {
string line;
StringBuilder textBuilder = new StringBuilder();
// Read block
while ((not_eof = (line = Console.In.ReadLine()) != null) && line.Length > 0) {
textBuilder.Append(line).Append('\n');
}
if (not_eof) textBuilder.Append('\n');
// Tokenize and tag
string text = textBuilder.ToString();
tokenizer.setText(text);
int t = 0;
while (tokenizer.nextSentence(forms, tokens)) {
tagger.tag(forms, lemmas);
for (int i = 0; i < lemmas.Count; i++) {
TaggedLemma lemma = lemmas[i];
int token_start = (int)tokens[i].start, token_length = (int)tokens[i].length;
xmlOut.WriteString(text.Substring(t, token_start - t));
if (i == 0) xmlOut.WriteStartElement("sentence");
xmlOut.WriteStartElement("token");
xmlOut.WriteAttributeString("lemma", lemma.lemma);
xmlOut.WriteAttributeString("tag", lemma.tag);
xmlOut.WriteString(text.Substring(token_start, token_length));
xmlOut.WriteEndElement();
if (i + 1 == lemmas.Count) xmlOut.WriteEndElement();
t = token_start + token_length;
}
}
xmlOut.WriteString(text.Substring(t));
}
return 0;
}
示例2: 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 ();
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: GetRssFeedContens
private void GetRssFeedContens(AspxCommonInfo aspxCommonObj, string pageURL, int count)
{
try
{
string[] path = pageURL.Split('?');
string pagepath = path[0];
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "text/xml";
XmlTextWriter rssXml = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
rssXml.WriteStartDocument();
rssXml.WriteStartElement("rss");
rssXml.WriteAttributeString("version", "2.0");
rssXml.WriteStartElement("channel");
rssXml.WriteElementString("link", pagepath);
rssXml.WriteElementString("title", getLocale("AspxCommerce Services"));
GetItemRssFeedContents(aspxCommonObj, rssXml, pageURL,count);
rssXml.WriteEndElement();
rssXml.WriteEndElement();
rssXml.WriteEndDocument();
rssXml.Flush();
rssXml.Close();
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
throw ex;
}
}
示例7: Main
static void Main()
{
using (var writer = new XmlTextWriter(filePath, encoding))
{
writer.Formatting = Formatting.Indented;
writer.IndentChar = '\t';
writer.Indentation = 1;
writer.WriteStartDocument();
writer.WriteStartElement("catalogue");
writer.WriteAttributeString("name", "Awesome Mix Vol. 1");
WriteAlbum(writer, "Hooked on a Feeling", "Blue Swede", 1968, "Scepter Records", 20);
WriteAlbum(writer, "Record World", "Raspberries", 1972, "Capitol Records", 18.50m,
new List<string>() { "Don't Want to Say Goodbye", "Go All the Way", "I Wanna Be with You" });
WriteAlbum(writer, "Starting Over", "Raspberries", 1974, "Capitol", 17.50m);
WriteAlbum(writer, "Wovoka", "Redbone", 1974, "Lolly Vegas", 11,
new List<string>() { "Come and Get Your Love", "When You Got Trouble" });
WriteAlbum(writer, "The 5th Dimension", "Blue Swede", 1974, "Warner Bros.", 9.99m);
writer.WriteEndDocument();
}
Console.WriteLine("Document saved to {0}", filePath);
}
示例8: WriteXmlReport
public static void WriteXmlReport(IEnumerable<XmlReport> reports)
{
string fileName = "../../../Sales-by-Vendors-report.xml";
Encoding encoding = Encoding.GetEncoding("windows-1251");
using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
{
writer.Formatting = Formatting.Indented;
writer.IndentChar = '\t';
writer.Indentation = 1;
writer.WriteStartDocument();
writer.WriteStartElement("sales");
string vendorName = "";
bool isFirst = true;
foreach (var report in reports)
{
if (report.VendorName !=vendorName && isFirst == true)
{
writer.WriteStartElement("sale");
writer.WriteAttributeString("vendor", report.VendorName);
writer.WriteStartElement("summary");
writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
writer.WriteAttributeString("total-sum", report.Sum.ToString());
writer.WriteEndElement();
vendorName = report.VendorName;
isFirst = false;
}
else if (report.VendorName !=vendorName && isFirst == false)
{
writer.WriteEndElement();
writer.WriteStartElement("sale");
writer.WriteAttributeString("vendor", report.VendorName);
writer.WriteStartElement("summary");
writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
writer.WriteAttributeString("total-sum", report.Sum.ToString());
writer.WriteEndElement();
vendorName = report.VendorName;
}
else
{
writer.WriteStartElement("summary");
writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
writer.WriteAttributeString("total-sum", report.Sum.ToString());
writer.WriteEndElement();
}
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
示例9: collapseAll
private static void collapseAll(XmlTextWriter writer, string directory)
{
foreach (var dir in Directory.GetDirectories(directory))
{
writer.WriteStartElement("dir");
writer.WriteAttributeString("path", directory.TrimStart('.', '\\'));
collapseAll(writer, dir); // using recursion to expand and search in all subfolders
writer.WriteEndElement();
}
foreach (var file in Directory.GetFiles(directory))
{
writer.WriteStartElement("file");
writer.WriteAttributeString("name", file.Substring(file.LastIndexOf('\\') + 1)); //using the Substring() method
writer.WriteEndElement(); //to remove the file path and
//write only the name of the file
}
}
示例10: AddRSSItem
public XmlTextWriter AddRSSItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, string datetime)
{
string itemname = System.IO.Path.GetFileName(sItemLink);
writer.WriteStartElement("item");
writer.WriteElementString("title", sItemTitle);
writer.WriteElementString("link", "http://www.weavver.com/?redirect=" + itemname);
writer.WriteElementString("description", "");
writer.WriteElementString("author", "Jane Doe");
writer.WriteElementString("contact", "tel://17148531212");
writer.WriteElementString("pubDate", datetime);
writer.WriteElementString("tags", "Unheard,Work");
writer.WriteStartElement("enclosure");
writer.WriteAttributeString("url", "http://www.weavver.com/messages/" + itemname);
writer.WriteAttributeString("length", "572345");
writer.WriteAttributeString("type", "audio/wav");
writer.WriteStartElement("transcription");
writer.WriteAttributeString("confidence", "1.0");
writer.WriteValue("THIS IS THE TRANSCRIPTION.");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
return writer;
}
示例11: 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;
}
示例12: WriteRSSPrologue
public XmlTextWriter WriteRSSPrologue(XmlTextWriter writer)
{
writer.WriteStartDocument();
writer.WriteStartElement("rss");
writer.WriteAttributeString("version", "2.0");
//writer.WriteAttributeString("xmlns:atom", "xmlns:blogChannel", "http://feeds.weavver.com");
writer.WriteStartElement("channel");
writer.WriteElementString("title", "John Doe's Weavver Feed");
writer.WriteElementString("link", "http://my.weavver.com");
writer.WriteElementString("language", "en-us");
writer.WriteElementString("description", "");
writer.WriteElementString("copyright", "Copyright 2002-2003 Feed");
writer.WriteElementString("generator", "Weavver Syndication");
return writer;
}
示例13: 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();
}
示例14: 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();
}
示例15: 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();
}