本文整理汇总了C#中XmlTextWriter.WriteStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteStartElement方法的具体用法?C# XmlTextWriter.WriteStartElement怎么用?C# XmlTextWriter.WriteStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteStartElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: 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();
}
示例3: BuildXMLString
private string BuildXMLString()
{
StringWriter str = new StringWriter();
XmlTextWriter xml = new XmlTextWriter(str);
// start doc and root el.
xml.WriteStartDocument();
xml.WriteStartElement("playerScoreList");
// data element
xml.WriteStartElement("player");
xml.WriteElementString("name", "matt");
xml.WriteElementString("score", "200");
xml.WriteEndElement();
// data element
xml.WriteStartElement("player");
xml.WriteElementString("name", "jane");
xml.WriteElementString("score", "150");
xml.WriteEndElement();
// end root and document
xml.WriteEndElement();
xml.WriteEndDocument();
return str.ToString();
}
示例4: 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;
}
示例5: PrintReviews
public static void PrintReviews(XmlTextWriter writer, IList<Review> reviews)
{
writer.WriteStartElement("result-set");
foreach (var review in reviews)
{
writer.WriteStartElement("review");
string dateStr = review.Date.ToString(
Constants.DATE_FORMAT, Constants.DEFAULT_CULTURE);
writer.WriteElementString("date", dateStr);
writer.WriteElementString("content", review.Content);
Book book = review.Book;
writer.WriteStartElement("book");
writer.WriteElementString("title", book.Title);
if (book.Authors.Count > 0)
{
string bookAuthors = string.Join(", ",
book.Authors.OrderBy(a => a.Name).Select(a => a.Name));
writer.WriteElementString("authors", bookAuthors);
}
if (book.ISBN != null)
{
writer.WriteElementString("isbn", book.ISBN);
}
if (book.Url != null)
{
writer.WriteElementString("url", book.Url);
}
writer.WriteEndElement();
writer.WriteEndElement();
}
writer.WriteEndElement();
}
示例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: TreverseDirectories
private static void TreverseDirectories(XmlTextWriter writer, DirectoryInfo dir)
{
var folders = dir.GetDirectories();
var files = dir.GetFiles();
writer.WriteStartElement("folder");
writer.WriteElementString("name", dir.Name);
try
{
if (files.Count() > 0)
{
writer.WriteStartElement("files");
foreach (var file in files)
{
writer.WriteElementString("name", file.Name);
}
writer.WriteEndElement();
}
foreach (var child in folders)
{
TreverseDirectories(writer, child);
}
writer.WriteEndElement();
}
catch (Exception)
{
Console.WriteLine("Access denied! ");
}
}
示例8: WriteBookmarks
private static void WriteBookmarks(
XmlTextWriter writer, IList<Bookmark> bookmarks)
{
writer.WriteStartElement("result-set");
foreach (var bookmark in bookmarks)
{
writer.WriteStartElement("bookmark");
if (bookmark.User.Username != null)
{
writer.WriteElementString("username", bookmark.User.Username);
}
if (bookmark.Title != null)
{
writer.WriteElementString("title", bookmark.Title);
}
if (bookmark.URL != null)
{
writer.WriteElementString("url", bookmark.URL);
}
if (bookmark.Tags.Count > 0)
{
string tags = string.Join(", ",
bookmark.Tags.Select(t => t.Name).OrderBy(t => t));
writer.WriteElementString("tags", tags);
}
if (bookmark.Notes != null)
{
writer.WriteElementString("notes", bookmark.Notes);
}
writer.WriteEndElement();
}
writer.WriteEndElement();
}
示例9: WriteGestureLog
public void WriteGestureLog(Dictionary<String, Point3D> gestureDict, string timeStamp)
{
using (StringWriter sw = new StringWriter(_sBuilder))
{
using (XmlWriter xmlWriter = new XmlTextWriter(sw))
{
//START MOVEMENT
xmlWriter.WriteStartElement("mov");
xmlWriter.WriteStartAttribute("time_stamp");
xmlWriter.WriteValue(timeStamp);
xmlWriter.WriteEndAttribute();
//PRINT ALL JOINTS
foreach (var point in gestureDict)
{
xmlWriter.WriteStartElement(point.Key);//START JOINT
xmlWriter.WriteStartElement("x");
xmlWriter.WriteValue(point.Value.X);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("Y");
xmlWriter.WriteValue(point.Value.Y);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("Z");
xmlWriter.WriteValue(point.Value.Z);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();//END JOINT
}
xmlWriter.WriteEndElement();//END MOV
}
}
WriteToXMLLogFile();
}
示例10: Main
static void Main()
{
XmlReader reader = XmlReader.Create("../../catalogue.xml");
using (reader)
{
StreamWriter textWriter = new StreamWriter("../../albums.xml", false, Encoding.GetEncoding("utf-8"));
XmlTextWriter writer = new XmlTextWriter(textWriter);
using (writer)
{
writer.WriteStartDocument();
writer.WriteStartElement("album-catalog");
while (reader.Read())
{
if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "album"))
{
writer.WriteStartElement("album");
reader.ReadToDescendant("name");
writer.WriteElementString(reader.Name, reader.ReadInnerXml());
reader.ReadToNextSibling("artist");
writer.WriteElementString(reader.Name, reader.ReadInnerXml());
writer.WriteEndElement();
}
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
}
示例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");
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();
}
示例12: 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();
}
示例13: btnAdd_Click
protected void btnAdd_Click(object sender, EventArgs e)
{
XmlTextWriter xr = new XmlTextWriter(Server.MapPath("my.xml"), null);
xr.WriteStartDocument();
xr.WriteStartElement("Information");
xr.WriteStartElement("infos");
xr.WriteElementString("info", Editor1.Content);
xr.WriteEndElement();
xr.WriteEndElement();
xr.WriteEndDocument();
xr.Close();
Fillinfos();
Editor1.Content = "";
}
示例14: 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;
}
示例15: 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;
}