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


C# XmlTextWriter.WriteString方法代码示例

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


在下文中一共展示了XmlTextWriter.WriteString方法的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;
    }
开发者ID:ufal,项目名称:morphodita,代码行数:60,代码来源:RunTagger.cs

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

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

示例4: WriteProductItem

    } // End of the Create method

    /// <summary>
    /// Write one product item to the file
    /// </summary>
    /// <param name="writer">A reference to an xml text writer</param>
    /// <param name="domain">A reference to a domain</param>
    /// <param name="country">A referende to a country</param>
    /// <param name="product">A reference to a product</param>
    /// <param name="currency">A reference to a currency</param>
    /// <param name="decimalMultiplier">The decimal multiplier</param>
    /// <param name="googleVariants">A list with google variants</param>
    private static void WriteProductItem(XmlTextWriter writer, Domain domain, Country country, Product product, Currency currency, 
        Int32 decimalMultiplier, List<string[]> googleVariants)
    {     
        // Get the value added tax
        ValueAddedTax valueAddedTax = ValueAddedTax.GetOneById(product.value_added_tax_id);

        // Get the unit
        Unit unit = Unit.GetOneById(product.unit_id, domain.front_end_language);

        // Get the comparison unit
        Unit comparisonUnit = Unit.GetOneById(product.comparison_unit_id, domain.front_end_language);
        string comparison_unit_code = comparisonUnit != null ? comparisonUnit.unit_code_si : "na";

        // Get the category
        Category category = Category.GetOneById(product.category_id, domain.front_end_language);

        // Get a chain of parent categories
        List<Category> parentCategoryChain = Category.GetParentCategoryChain(category, domain.front_end_language);

        // Create the category string
        string categoryString = "";
        for (int i = 0; i < parentCategoryChain.Count; i++)
        {
            categoryString += parentCategoryChain[i].title;

            if(i < parentCategoryChain.Count - 1)
            {
                categoryString += " > ";
            }
        }

        // Write the start item tag
        writer.WriteStartElement("item");

        // Remove html from the title and the main content
        string title = StringHtmlExtensions.StripHtml(product.title);
        title = AnnytabDataValidation.TruncateString(title, 150);
        string main_content = Regex.Replace(product.main_content, @"(<br\s*[\/]>)+", " ");
        main_content = StringHtmlExtensions.StripHtml(main_content);
        main_content = Regex.Replace(main_content, @"\r\n?|\n", "");
        main_content = AnnytabDataValidation.TruncateString(main_content, 5000);

        // Write item base information
        writer.WriteStartElement("g:id");
        writer.WriteString(product.product_code);
        writer.WriteEndElement();
        writer.WriteStartElement("title");
        writer.WriteString(title);
        writer.WriteEndElement();
        writer.WriteStartElement("description");
        writer.WriteString(main_content);
        writer.WriteEndElement();
        writer.WriteStartElement("g:google_product_category");
        writer.WriteString(product.google_category);
        writer.WriteEndElement();
        writer.WriteStartElement("g:product_type");
        writer.WriteString(categoryString);
        writer.WriteEndElement();
        writer.WriteStartElement("link");
        writer.WriteString(domain.web_address + "/home/product/" + product.page_name);
        writer.WriteEndElement();
        writer.WriteStartElement("g:image_link");
        writer.WriteString(domain.web_address + Tools.GetProductMainImageUrl(product.id, domain.front_end_language, product.variant_image_filename, product.use_local_images));
        writer.WriteEndElement();
        writer.WriteStartElement("g:condition");
        writer.WriteString(product.condition != "" ? product.condition : "new");
        writer.WriteEndElement();

        // Calculate the price
        decimal basePrice = product.unit_price * (currency.currency_base / currency.conversion_rate);
        decimal regularPrice = Math.Round(basePrice * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        decimal salePrice = Math.Round(basePrice * (1 - product.discount) * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Get the country code as upper case letters
        string countryCodeUpperCase = country.country_code.ToUpper();

        // Add value added tax to the price
        if (countryCodeUpperCase != "US" && countryCodeUpperCase != "CA" && countryCodeUpperCase != "IN")
        {
            regularPrice += Math.Round(regularPrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
            salePrice += Math.Round(salePrice * valueAddedTax.value * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;
        }

        // Calculate the freight
        decimal freight = (product.unit_freight + product.toll_freight_addition) * (currency.currency_base / currency.conversion_rate);
        freight = Math.Round(freight * decimalMultiplier, MidpointRounding.AwayFromZero) / decimalMultiplier;

        // Add value added tax to the freight
//.........这里部分代码省略.........
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:101,代码来源:GoogleShopping.cs

示例5: CreateUrlPost

    } // End of the CreateSitemap method

    /// <summary>
    /// Create a url post
    /// </summary>
    /// <param name="xmlTextWriter">A reference to a XmlTextWriter</param>
    /// <param name="url">The url as a string</param>
    /// <param name="priority">The priority as a string</param>
    /// <param name="changeFrequency">The change frequency</param>
    /// <param name="lastModifiedDate">The date for the last modification</param>
    private static void CreateUrlPost(XmlTextWriter xmlTextWriter, string url, string priority, string changeFrequency, DateTime lastModifiedDate)
    {
        xmlTextWriter.WriteStartElement("url");
        xmlTextWriter.WriteStartElement("loc");
        xmlTextWriter.WriteString(url);
        xmlTextWriter.WriteEndElement();
        xmlTextWriter.WriteStartElement("lastmod");
        xmlTextWriter.WriteString(string.Format("{0:yyyy-MM-dd}", lastModifiedDate));
        xmlTextWriter.WriteEndElement();
        xmlTextWriter.WriteStartElement("changefreq");
        xmlTextWriter.WriteString(changeFrequency);
        xmlTextWriter.WriteEndElement();
        xmlTextWriter.WriteStartElement("priority");
        xmlTextWriter.WriteString(priority);
        xmlTextWriter.WriteEndElement();
        xmlTextWriter.WriteEndElement();

    } // End of the CreateUrlPost method
开发者ID:hunii,项目名称:a-blogsite,代码行数:28,代码来源:SitemapManager.cs

示例6: Save

 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     if (null != _value) { writer.WriteString(_value); }
     writer.WriteEndElement();
 }
开发者ID:Gamieon,项目名称:Cycles3D,代码行数:6,代码来源:XmlCollada.cs

示例7: CreateXmlRow

    } // End of the SetDatabaseVersion method

    /// <summary>
    /// Create a xml row
    /// </summary>
    /// <param name="xmlTextWriter">A reference to a XmlTextWriter</param>
    /// <param name="name">The name of the xml tag</param>
    /// <param name="value">The value of the xml tag</param>
    private static void CreateXmlRow(XmlTextWriter xmlTextWriter, string name, string value)
    {
        xmlTextWriter.WriteStartElement(name);
        xmlTextWriter.WriteString(value);
        xmlTextWriter.WriteEndElement();

    } // End of the CreateXmlRow method
开发者ID:hunii,项目名称:a-blogsite,代码行数:15,代码来源:DatabaseManager.cs

示例8: CreateStylesheet

		// Function  : WriteStylesheet 
		// Arguments : writer, sHeaders, sFileds, FormatType
		// Purpose   : Creates XSLT file to apply on dataset's XML file 

		private void CreateStylesheet(XmlTextWriter writer, string[] sHeaders, string[] sFileds, ExportFormat FormatType)
		{
			try
			{
				// xsl:stylesheet
				string ns = "http://www.w3.org/1999/XSL/Transform";	
				writer.Formatting = Formatting.Indented;
				writer.WriteStartDocument( );				
				writer.WriteStartElement("xsl","stylesheet",ns);
				writer.WriteAttributeString("version","1.0");
				writer.WriteStartElement("xsl:output");
				writer.WriteAttributeString("method","text");
				writer.WriteAttributeString("version","4.0");
				writer.WriteEndElement( );
				
				// xsl-template
				writer.WriteStartElement("xsl:template");
				writer.WriteAttributeString("match","/");

				// xsl:value-of for headers
				for(int i=0; i< sHeaders.Length; i++)
				{
					writer.WriteString("\"");
					writer.WriteStartElement("xsl:value-of");
					writer.WriteAttributeString("select", "'" + sHeaders[i] + "'");
					writer.WriteEndElement( ); // xsl:value-of
					writer.WriteString("\"");
					if (i != sFileds.Length - 1) writer.WriteString( (FormatType == ExportFormat.CSV ) ? "," : "	" );
				}
								
				// xsl:for-each
				writer.WriteStartElement("xsl:for-each");
				writer.WriteAttributeString("select","Export/Values");
				writer.WriteString("\r\n");				
				
				// xsl:value-of for data fields
				for(int i=0; i< sFileds.Length; i++)
				{					
					writer.WriteString("\"");
					writer.WriteStartElement("xsl:value-of");
					writer.WriteAttributeString("select", sFileds[i]);
					writer.WriteEndElement( ); // xsl:value-of
					writer.WriteString("\"");
					if (i != sFileds.Length - 1) writer.WriteString( (FormatType == ExportFormat.CSV ) ? "," : "	" );
				}
								
				writer.WriteEndElement( ); // xsl:for-each
				writer.WriteEndElement( ); // xsl-template
				writer.WriteEndElement( ); // xsl:stylesheet
				writer.WriteEndDocument( );					
			}
			catch(Exception Ex)
			{
				throw Ex;
			}
		}
开发者ID:ViniciusConsultor,项目名称:sqlschematool,代码行数:60,代码来源:ExportData.cs

示例9: Matricularse2_Click

    protected void Matricularse2_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);

        if (Nombre2.Text == "" || Apellido2.Text == "" || DNI2.Text == "" || Direccion2.Text == "" || Telefono2.Text == "" || Celular2.Text == "" || Correo_electronico2.Text == "")
        {
            registro2.Style["color"] = "Red";
            registro2.Text = "MATRICULA NO REGISTRADA, llene todos los campos...";
        }
        else
        {

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO Sociales VALUES (@nombre, @apellidos, @DNI, @fechanac,@genero,@grado,@seccion,@escuela,@region,@distrito,@direccion,@telefono,@celular,@email)";
            cmd.Parameters.Add("@nombre", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@apellidos", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@DNI", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@fechanac", System.Data.SqlDbType.Date);
            cmd.Parameters.Add("@genero", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@grado", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@seccion", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@escuela", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@region", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@distrito", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@direccion", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@telefono", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@celular", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar);
            //cmd.Parameters.Add("@foto", System.Data.SqlDbType.Image).Value=photo;

            cmd.Parameters["@nombre"].Value = Nombre2.Text;
            cmd.Parameters["@apellidos"].Value = Apellido2.Text;
            cmd.Parameters["@DNI"].Value = Int32.Parse(DNI2.Text); ;
            cmd.Parameters["@fechanac"].Value = Dias2.Text + "-" + Meses2.Text + "-" + Años2.Text;
            cmd.Parameters["@genero"].Value = genero.Text;
            cmd.Parameters["@grado"].Value = Grado2.SelectedItem.Text;
            cmd.Parameters["@seccion"].Value = Seccion2.SelectedItem.Text;
            cmd.Parameters["@escuela"].Value = Escuela2.SelectedItem.Text;
            cmd.Parameters["@region"].Value = Region2.SelectedItem.Text;
            cmd.Parameters["@distrito"].Value = Distrito2.SelectedItem.Text;
            cmd.Parameters["@direccion"].Value = Direccion2.Text;
            cmd.Parameters["@telefono"].Value = Int32.Parse(Telefono2.Text);
            cmd.Parameters["@celular"].Value = Int32.Parse(Celular2.Text);
            cmd.Parameters["@email"].Value = Correo_electronico2.Text;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                registro2.Style["color"] = "Blue";
                registro2.Text = "MATRICULA REGISTRADA";
                con.Close();

            }
            catch (Exception err)
            {
                registro2.Text = "Error al registrar alumno";
                registro2.Text += err.Message;
            }
            Cursos0.Visible = true;
            FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                        FileMode.Create);
            XmlTextWriter w = new XmlTextWriter(fs, null);

            w.WriteStartDocument();
            w.WriteStartElement("SuperProProductList");
            w.WriteComment("This file generated by the XmlTextWriter class.");

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "1");
            w.WriteAttributeString("Nombre_Utiles", "", "Psicología");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "2");
            w.WriteAttributeString("Nombre_Utiles", "", "Propedeútica del Trabajo");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("Codigo", "", "3");
            w.WriteAttributeString("Nombre_Utiles", "", "Comu. Oral y Escrit");

            w.WriteStartElement("Creditos");
            w.WriteString("3");
            w.WriteEndElement();

            w.WriteEndElement();

//.........这里部分代码省略.........
开发者ID:iguilleng,项目名称:proyectofinal,代码行数:101,代码来源:matricula.aspx.cs

示例10: Matricularse0_Click

    protected void Matricularse0_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);

        if (Nombre0.Text == "" || Apellido0.Text == "" || DNI0.Text == "" || Direccion0.Text == "" || Telefono0.Text == "" || Celular0.Text == "" || Correo_electronico0.Text == "")
        {
            registro0.Style["color"] = "Red";
            registro0.Text = "MATRICULA NO REGISTRADA, llene todos los campos...";
        }
        else
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandText = "INSERT INTO Ingenierias VALUES (@nombre, @apellidos, @DNI, @fechanac,@genero,@grado,@seccion,@escuela,@region,@distrito,@direccion,@telefono,@celular,@email)";
            cmd.Parameters.Add("@nombre", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@apellidos", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@DNI", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@fechanac", System.Data.SqlDbType.Date);
            cmd.Parameters.Add("@genero", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@grado", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@seccion", System.Data.SqlDbType.NChar);
            cmd.Parameters.Add("@escuela", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@region", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@distrito", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@direccion", System.Data.SqlDbType.NVarChar);
            cmd.Parameters.Add("@telefono", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@celular", System.Data.SqlDbType.Int);
            cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar);
            //cmd.Parameters.Add("@foto", System.Data.SqlDbType.Image).Value=photo;

            cmd.Parameters["@nombre"].Value = Nombre0.Text;
            cmd.Parameters["@apellidos"].Value = Apellido0.Text;
            cmd.Parameters["@DNI"].Value = Int32.Parse(DNI0.Text); ;
            cmd.Parameters["@fechanac"].Value = Dias0.Text + "-" + Meses0.Text + "-" + Años0.Text;
            cmd.Parameters["@genero"].Value = genero0.SelectedItem.Text;
            cmd.Parameters["@grado"].Value = Grado.SelectedItem.Text;
            cmd.Parameters["@seccion"].Value = Seccion.SelectedItem.Text;
            cmd.Parameters["@escuela"].Value = Escuela.SelectedItem.Text;
            cmd.Parameters["@region"].Value = Region0.SelectedItem.Text;
            cmd.Parameters["@distrito"].Value = Distrito0.SelectedItem.Text;
            cmd.Parameters["@direccion"].Value = Direccion0.Text;
            cmd.Parameters["@telefono"].Value = Int32.Parse(Telefono0.Text);
            cmd.Parameters["@celular"].Value = Int32.Parse(Celular0.Text);
            cmd.Parameters["@email"].Value = Correo_electronico0.Text;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                registro0.Style["color"] = "Blue";
                registro0.Text = "MATRICULA REGISTRADA";
                con.Close();

            }
            catch (Exception err)
            {
                registro0.Text = "Error al registrar alumno";
                registro0.Text += err.Message;
            }

            Cursos.Visible = true;
            FileStream fs = new FileStream(@"F:\SuperProProductList.xml",
                         FileMode.Create);
            XmlTextWriter w = new XmlTextWriter(fs, null);

            w.WriteStartDocument();
            w.WriteStartElement("SuperProProductList");
            w.WriteComment("This file generated by the XmlTextWriter class.");

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "1");
            w.WriteAttributeString("Curso", "", "ALGEBRA Y GEOMETRIA");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "2");
            w.WriteAttributeString("Curso", "", "INGENIERIA DE SISTEMAS");

            w.WriteStartElement("Creditos");
            w.WriteString("4");
            w.WriteEndElement();

            w.WriteEndElement();

            w.WriteStartElement("Lista_Utiles");
            w.WriteAttributeString("id", "", "3");
            w.WriteAttributeString("Curso", "", "PROPEDEUTICA");

            w.WriteStartElement("Creditos");
            w.WriteString("2");
            w.WriteEndElement();

            w.WriteEndElement();

//.........这里部分代码省略.........
开发者ID:iguilleng,项目名称:proyectofinal,代码行数:101,代码来源:matricula.aspx.cs

示例11: PersistToIsolatedStorage

    private void PersistToIsolatedStorage()
    {
        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
        using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("UserSettings.xml", System.IO.FileMode.Create, isf))
        {
            System.Xml.XmlTextWriter xtw = new XmlTextWriter(isfs, System.Text.Encoding.Default);

            xtw.WriteStartDocument();
            xtw.WriteStartElement("UserSettings");
            xtw.WriteStartElement("LastPattern");
            xtw.WriteString(this.textboxPattern.Text);
            xtw.WriteEndElement();
            xtw.WriteEndElement();
            xtw.WriteEndDocument();

            xtw.Close();
        }
    }
开发者ID:glenncarr,项目名称:glenns-rsar,代码行数:18,代码来源:PromptForArgs.cs

示例12: WriteNode

	public static void WriteNode(XmlElement node, string method, XmlTextWriter output, TextWriter raw) {
		if (node.Name == "string") {
			output.WriteString(node.InnerText);
			return;
		}
		
		if (node.Name == "Attribute")
			output.WriteStartAttribute(node.GetAttribute("Name"), "");
		else if (node.Name == "Text") {
		}
		else if (node.Name != "Element")
			output.WriteStartElement(node.Name);
		else
			output.WriteStartElement(node.GetAttribute("Name"));
		
		foreach (XmlElement child in node.SelectNodes("*")) {
			string status = child.GetAttribute("Status");
			if (status == "") {
				WriteNode(child, method, output, raw);
			} else if (status == "Same") {
				WriteNodeRaw(child, method, output);
			} else if (status == "Added" || status == "Removed") {
				output.Flush();
				if (method == "text") {
					if (status == "Added") raw.Write("\n+"); else raw.Write("\n-");
				} else if (method == "groff") {
					if (status == "Added") raw.Write("\\m[blue]"); else raw.Write("\\m[red]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n");
				} else if (method == "groff") {
					if (status == "Added") raw.Write("\\m[]"); else raw.Write("\\m[]");
				}
				raw.Flush();
			} else if (status == "Changed") {
				output.Flush();
				if (method == "text") {
					raw.Write("\n-");
				} else if (method == "groff") {
					raw.Write("\\m[green]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n+");
				} else if (method == "groff") {
					raw.Write("\\m[]\\m[magenta]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild.NextSibling, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n");
				} else if (method == "groff") {
					raw.Write("\\m[]");
				}
				raw.Flush();
			} else {
				throw new InvalidOperationException("Bad status: " + status);
			}
		}

		if (node.FirstChild is XmlText)
			output.WriteString(node.FirstChild.Value);		
		
		if (node.Name == "Attribute")
			output.WriteEndAttribute();
		else if (node.Name == "Text")
		{}
		else
			output.WriteEndElement();
	}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:82,代码来源:XmlDiff.cs

示例13: WriteNodeRaw

	public static void WriteNodeRaw(XmlElement node, string method, XmlTextWriter output) {
		if (node.Name == "string") {
			output.WriteString(node.InnerText + "\n");
			return;
		} else if (node.Name == "Text") {
			output.WriteString(node.Value);
			return;
		} else if (node.Name == "Attribute") {
			output.WriteAttributeString(node.GetAttribute("Name"), "", node.InnerText);
			return;
		} else if (node.Name != "Element") {
			output.WriteStartElement(node.Name);
		} else {
			output.WriteStartElement(node.GetAttribute("Name"));
		}

		foreach (XmlNode child in node.SelectNodes("@*|*")) {
			if (child is XmlAttribute && child.Name == "Status")
				continue;
			child.WriteTo(output);
		}
		
		if (node.FirstChild is XmlText)
			output.WriteString(node.FirstChild.Value);
		
		output.WriteEndElement();
	}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:27,代码来源:XmlDiff.cs

示例14: Create

    /// <summary>
    /// Create a google shopping file
    /// </summary>
    /// <param name="domain">A reference to the domain</param>
    public static void Create(Domain domain)
    {

        // Create the directory path
        string directoryPath = HttpContext.Current.Server.MapPath("/Content/domains/" + domain.id.ToString() + "/marketing/");

        // Check if the directory exists
        if (System.IO.Directory.Exists(directoryPath) == false)
        {
            // Create the directory
            System.IO.Directory.CreateDirectory(directoryPath);
        }

        // Create the file
        string filepath = directoryPath + "GoogleShopping.xml.gz";

        // Get all data that we need
        List<Product> products = Product.GetAllActive(domain.front_end_language, "title", "ASC");
        Currency currency = Currency.GetOneById(domain.currency);
        Int32 decimalMultiplier = (Int32)Math.Pow(10, currency.decimals);
        Country country = Country.GetOneById(domain.country_id, domain.front_end_language);

        // Create variables
        GZipStream gzipStream = null;
        XmlTextWriter xmlTextWriter = null;

        try
        {
            // Create a gzip stream
            gzipStream = new GZipStream(new FileStream(filepath, FileMode.Create), CompressionMode.Compress);

            // Create a xml text writer
            xmlTextWriter = new XmlTextWriter(gzipStream, new UTF8Encoding(true));

            // Set the base url
            string baseUrl = domain.web_address;

            // Write the start of the document
            xmlTextWriter.WriteStartDocument();

            // Write the rss tag
            xmlTextWriter.WriteStartElement("rss");
            xmlTextWriter.WriteAttributeString("version", "2.0");
            xmlTextWriter.WriteAttributeString("xmlns:g", "http://base.google.com/ns/1.0");

            // Write the channel tag
            xmlTextWriter.WriteStartElement("channel");

            // Write information about the channel
            xmlTextWriter.WriteStartElement("title");
            xmlTextWriter.WriteString(domain.webshop_name);
            xmlTextWriter.WriteEndElement();
            xmlTextWriter.WriteStartElement("link");
            xmlTextWriter.WriteString(baseUrl);
            xmlTextWriter.WriteEndElement();
            xmlTextWriter.WriteStartElement("description");
            xmlTextWriter.WriteString("Products");
            xmlTextWriter.WriteEndElement();

            // Loop all the products
            for (int i = 0; i < products.Count; i++)
            {
                // Do not include affiliate products
                if(products[i].affiliate_link != "")
                {
                    continue;
                }

                // Get all the product options
                List<ProductOptionType> productOptionTypes = ProductOptionType.GetByProductId(products[i].id, domain.front_end_language);
                
                // Check if the product has product options or not
                if (productOptionTypes.Count > 0)
                {
                    // Get all the product options
                    Dictionary<Int32, List<ProductOption>> productOptions = new Dictionary<Int32, List<ProductOption>>(productOptionTypes.Count);

                    // Loop all the product option types

                    for (int j = 0; j < productOptionTypes.Count; j++)
                    {
                        List<ProductOption> listProductOptions = ProductOption.GetByProductOptionTypeId(productOptionTypes[j].id, domain.front_end_language);
                        productOptions.Add(j, ProductOption.GetByProductOptionTypeId(productOptionTypes[j].id, domain.front_end_language));
                    }

                    // Get all the product combinations
                    List<ProductOption[]> productCombinations = new List<ProductOption[]>();
                    ProductOption.GetProductCombinations(productCombinations, productOptions, 0, new ProductOption[productOptions.Count]);

                    // Loop all the product combinations
                    foreach(ProductOption[] optionArray in productCombinations)
                    {
                        // Get a product copy
                        Product productCopy = products[i].Clone();

                        // Create an array with google variants
//.........这里部分代码省略.........
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:101,代码来源:GoogleShopping.cs

示例15: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["nid"] != null)
            {
                int nodeId = Convert.ToInt32(Request["nid"]);
                if (nodeId > 0)
                {
                    if (WAFContext.Session.ContentExists(nodeId))
                    {
                        Blog blog = WAFContext.Session.GetContent<Blog>(nodeId);
                        if (blog != null)
                        {
                            Response.Clear();
                            Response.ContentType = "text/xml";

                            XmlTextWriter xmlWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
                            xmlWriter.WriteStartDocument();
                            xmlWriter.WriteStartElement("rss");
                            xmlWriter.WriteAttributeString("version", "2.0");
                            xmlWriter.WriteStartElement("channel");
                            xmlWriter.WriteElementString("title", blog.Name);
                            xmlWriter.WriteElementString("link", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(blog.NodeId));
                            xmlWriter.WriteElementString("description", blog.MiniDescription);
                            xmlWriter.WriteElementString("generator", "Webscape.Net CMS");
                            List<BlogPost> blogPosts = blog.BlogPosts.Query<BlogPost>().OrderBy(AqlBlogPost.CreateDate, true).Where(AqlBlogPost.Published==true).Execute(blog.NumberOfPostsInRssFeed);
                            foreach (BlogPost post in blogPosts)
                            {
                                xmlWriter.WriteStartElement("item");
                                xmlWriter.WriteElementString("title", post.Name);
                                if (blog.ShowWholePost)
                                {
                                    xmlWriter.WriteElementString("description", HttpUtility.HtmlDecode(NewsletterUtil.ReplaceRelativeLinksWithAbsoluteLinks(post.Content, NewsletterUtil.GetBaseUrl(Request),WAFContext.UrlFromHostToApp)));
                                } else
                                {
                                    xmlWriter.WriteElementString("description", post.Ingress);
                                }
                                xmlWriter.WriteElementString("link", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(post.NodeId));
                                xmlWriter.WriteElementString("pubDate", BuildPubDate(post.CreateDate));
                                if (WAFContext.Session.ContentExists(post.AuthorId))
                                {
                                    SystemUser author = WAFContext.Session.GetContent<SystemUser>(post.AuthorId);
                                    xmlWriter.WriteElementString("author", author.Name);
                                }
                                foreach (BlogCategory cat in post.Categories.Get<BlogCategory>())
                                {
                                    //<category domain="http://www.fool.com/cusips">MSFT</category>
                                    xmlWriter.WriteStartElement("category");
                                    xmlWriter.WriteAttributeString("domain", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(blog.NodeId) + "&tag=" + cat.Name);
                                    xmlWriter.WriteString(cat.Name);
                                    xmlWriter.WriteEndElement();
                                }
                                xmlWriter.WriteEndElement();
                            }
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndDocument();
                            xmlWriter.Flush();
                            xmlWriter.Close();
                        }
                    }
                }
            } else
            {
                   Response.Clear();
                   Response.ContentType = "text/xml";

                   XmlTextWriter xmlWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
                   xmlWriter.WriteStartDocument();
                   xmlWriter.WriteStartElement("rss");
                   xmlWriter.WriteAttributeString("version", "2.0");
                   xmlWriter.WriteStartElement("channel");
                   xmlWriter.WriteElementString("title", "Latest blog posts");
                   xmlWriter.WriteElementString("link", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(161279));
                   xmlWriter.WriteElementString("description", "Latest blog posts");
                   xmlWriter.WriteElementString("genrator", "WAF ASP.Net CMS");
                   List<BlogPost> blogPosts = WAFContext.Session.Query<BlogPost>().OrderBy(AqlBlogPost.CreateDate, true).Execute(15);
                   foreach(BlogPost post in blogPosts) {
                          xmlWriter.WriteStartElement("item");
                          xmlWriter.WriteElementString("title", post.Name);
                          xmlWriter.WriteElementString("description", HttpUtility.HtmlDecode(NewsletterUtil.ReplaceRelativeLinksWithAbsoluteLinks(post.Content, NewsletterUtil.GetBaseUrl(Request),WAFContext.UrlFromHostToApp)));
                          xmlWriter.WriteElementString("link", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(post.NodeId));
                          xmlWriter.WriteElementString("pubDate", BuildPubDate(post.CreateDate));
                          if(WAFContext.Session.ContentExists(post.AuthorId)) {
                                 SystemUser author = WAFContext.Session.GetContent<SystemUser>(post.AuthorId);
                                 xmlWriter.WriteElementString("author", author.Name);
                          }
                          foreach(BlogCategory cat in post.Categories.Get<BlogCategory>()) {
                                 xmlWriter.WriteStartElement("category");
                                 xmlWriter.WriteAttributeString("domain", NewsletterUtil.GetBaseUrl(Request) + WAFContext.GetUrlFromHostToQueryVirtualView(post.Blog.Get().NodeId) + "&tag=" + cat.Name);
                                 xmlWriter.WriteString(cat.Name);
                                 xmlWriter.WriteEndElement();
                          }
                          xmlWriter.WriteEndElement();
                   }
                   xmlWriter.WriteEndElement();
                   xmlWriter.WriteEndElement();
                   xmlWriter.WriteEndDocument();
                   xmlWriter.Flush();
                   xmlWriter.Close();
            }
//.........这里部分代码省略.........
开发者ID:kyvkri,项目名称:mgone,代码行数:101,代码来源:Rss.aspx.cs


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