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


C# XmlTextWriter.WriteAttributeString方法代码示例

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


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

示例1: Serialize

        public static string Serialize(IEnumerable<MicroDataEntry> entries)
        {
            StringBuilder sb = new StringBuilder(3000);
            using (StringWriter sw = new StringWriter(sb))
            {
                using (XmlTextWriter xw = new XmlTextWriter(sw))
                {
                    xw.WriteStartElement("microData");

                    foreach (MicroDataEntry microDataEntry in entries)
                    {
                        xw.WriteStartElement("entry");

                        if (microDataEntry.ContentType.HasValue)
                        {
                            xw.WriteAttributeString("contentType", microDataEntry.ContentType.Value.ToString());
                        }

                        xw.WriteAttributeString("entryType", microDataEntry.Type.ToString());
                        xw.WriteAttributeString("selector", microDataEntry.Selector);
                        xw.WriteAttributeString("value", microDataEntry.Value);

                        xw.WriteEndElement();
                    }

                    xw.WriteEndElement();
                }
            }

            return sb.ToString();
        }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:31,代码来源:MicroDataSerializer.cs

示例2: button1_Click

 // XmlWriterSample1/form.cs
 private void button1_Click(object sender, System.EventArgs e)
 {
     // change to match you path structure
     string fileName="booknew.xml";
     //create the XmlTextWriter
     XmlTextWriter tw=new XmlTextWriter(fileName,null);
     //set the formatting to indented
     tw.Formatting=Formatting.Indented;
     tw.WriteStartDocument();
     //Start creating elements and attributes
     tw.WriteStartElement("book");
     tw.WriteAttributeString("genre","Mystery");
     tw.WriteAttributeString("publicationdate","2001");
     tw.WriteAttributeString("ISBN","123456789");
     tw.WriteElementString("title","Case of the Missing Cookie");
     tw.WriteStartElement("author");
     tw.WriteElementString("name","Cookie Monster");
     tw.WriteEndElement();
     tw.WriteElementString("price","9.99");
     tw.WriteEndElement();
     tw.WriteEndDocument();
     //clean up
     tw.Flush();
     tw.Close();
 }
开发者ID:alannet,项目名称:example,代码行数:26,代码来源:XmlWriterSample1.cs

示例3: SaveRegister

        private bool SaveRegister(string RegisterKey)
        {
            try
            {
                
                Encryption enc = new Encryption();
                FileStream fs = new FileStream("reqlkd.dll", FileMode.Create);
                XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

                // Khởi động tài liệu.
                w.WriteStartDocument();
                w.WriteStartElement("QLCV");

                // Ghi một product.
                w.WriteStartElement("Register");
                w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID));
                w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial));
                w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID));
                w.WriteEndElement();

                // Kết thúc tài liệu.
                w.WriteEndElement();
                w.WriteEndDocument();
                w.Flush();
                w.Close();
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
开发者ID:phinq19,项目名称:qlcongviec,代码行数:34,代码来源:frmRegister.cs

示例4: AddKey

 private void AddKey(XmlTextWriter xml, string key, string value)
 {
     xml.WriteStartElement("add");
     xml.WriteAttributeString("key", key);
     xml.WriteAttributeString("value", value);
     xml.WriteEndElement(); //add
 }
开发者ID:frapid,项目名称:frapid,代码行数:7,代码来源:ThemeCreator.cs

示例5: EncodeInvoke

        /// <summary> 
        /// Encodes a function call to be sent to Flash. 
        /// </summary> 
        /// <param name="functionName">The name of the function to call.</param> 
        /// <param name="arguments">Zero or more parameters to pass in to the ActonScript function.</param> 
        /// <returns>The XML string representation of the function call to pass to Flash</returns> 
        public static string EncodeInvoke(string functionName, object[] arguments)
        {
            StringBuilder sb = new StringBuilder();

            XmlTextWriter writer = new XmlTextWriter(new StringWriter(sb));

            // <invoke name="functionName" returntype="xml">
            writer.WriteStartElement("invoke");
            writer.WriteAttributeString("name", functionName);
            writer.WriteAttributeString("returntype", "xml");

            if (arguments != null && arguments.Length > 0)
            {
                // <arguments>
                writer.WriteStartElement("arguments");

                // individual arguments
                foreach (object value in arguments)
                {
                    WriteElement(writer, value);
                }

                // </arguments>
                writer.WriteEndElement();
            }

            // </invoke>
            writer.WriteEndElement();

            writer.Flush();
            writer.Close();

            return sb.ToString();
        }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:40,代码来源:ExternalInterfaceSerializer.cs

示例6: createRandomXML

        public void createRandomXML(XmlTextWriter writer, int NUM_SENSOR, int NUM_LINK)
        {
            writer.WriteStartElement(XmlTag.TAG_WSN);

            writer.WriteStartElement(XmlTag.TAG_DECLARATION);
            writer.WriteEndElement();

            writer.WriteStartElement(XmlTag.TAG_NETWORK);

            writer.WriteStartElement(XmlTag.TAG_PROCESS);
            writer.WriteAttributeString(XmlTag.ATTR_NAME, "Network_1");
            writer.WriteAttributeString(XmlTag.ATTR_PRO_PARAM, "");
            writer.WriteAttributeString(XmlTag.ATTR_ZOOM, "1");
            writer.WriteAttributeString("StateCounter", "9");

            //Create sensors
            writer.WriteStartElement(XmlTag.TAG_SENSORS);

            randomSensors(NUM_SENSOR, writer);
            writer.WriteEndElement(); //End sensors

            //Create links
            writer.WriteStartElement(XmlTag.TAG_CHANNELS);
            randomLinks(NUM_LINK, NUM_SENSOR, writer);
            writer.WriteEndElement(); //End <Links>

            writer.WriteEndElement(); //End <Process>
            writer.WriteEndElement(); //End <Network>
            writer.WriteEndElement(); //End <WSN>
        }
开发者ID:nhannhan159,项目名称:PAT,代码行数:30,代码来源:GraphXML.cs

示例7: TraverseAndGenerateXmlUsingXmlWriter

        // so not cool...
        private static void TraverseAndGenerateXmlUsingXmlWriter(string targetPath, XmlTextWriter writer)
        {
            var files = Directory.GetFiles(targetPath);
            if (files.Length > 0)
            {
                foreach (var f in files)
                {
                    writer.WriteStartElement("file");
                    writer.WriteAttributeString("name", Path.GetFileNameWithoutExtension(f));
                    writer.WriteEndElement();
                }
            }

            var directories = Directory.GetDirectories(targetPath);
            if (directories.Length != 0)
            {
                foreach (var dir in directories)
                {
                    writer.WriteStartElement("dir");
                    writer.WriteAttributeString("name", new DirectoryInfo(dir).Name);

                    TraverseAndGenerateXmlUsingXmlWriter(dir, writer);
                    writer.WriteEndElement();
                }
            }
        }
开发者ID:NikolaiMishev,项目名称:Databases,代码行数:27,代码来源:Start.cs

示例8: ToKML

 public override void ToKML(XmlTextWriter kml)
 {
     kml.WriteStartElement("Schema");
     kml.WriteAttributeString("name", Name);
     kml.WriteAttributeString("parent", Parent);
     kml.WriteEndElement();
 }
开发者ID:rupeshkumar399,项目名称:seemapcell,代码行数:7,代码来源:geSchema.cs

示例9: Serialize

        public static string Serialize(UserProfileData profile)
        {
            StringWriter sw = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);
            xtw.Formatting = Formatting.Indented;
            xtw.WriteStartDocument();
            
            xtw.WriteStartElement("user_profile");
            xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString());
            xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString());
                       
            xtw.WriteElementString("name", profile.Name);
            xtw.WriteElementString("id", profile.ID.ToString());
            xtw.WriteElementString("about", profile.AboutText);
  
            // Not sure if we're storing this yet, need to take a look
//            xtw.WriteElementString("Url", profile.Url);
            // or, indeed, interests

            xtw.WriteEndElement();
            
            xtw.Close();
            sw.Close();
            
            return sw.ToString();
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:26,代码来源:UserProfileSerializer.cs

示例10: WriteXml

        /// <summary>
        /// Generates Burn manifest and ParameterInfo-style markup for a component search.
        /// </summary>
        /// <param name="writer"></param>
        public override void WriteXml(XmlTextWriter writer)
        {
            writer.WriteStartElement("MsiComponentSearch");
            this.WriteWixSearchAttributes(writer);

            writer.WriteAttributeString("ComponentId", this.Guid);

            if (!String.IsNullOrEmpty(this.ProductCode))
            {
                writer.WriteAttributeString("ProductCode", this.ProductCode);
            }

            if (0 != (this.Attributes & WixComponentSearchAttributes.KeyPath))
            {
                writer.WriteAttributeString("Type", "keyPath");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.State))
            {
                writer.WriteAttributeString("Type", "state");
            }
            else if (0 != (this.Attributes & WixComponentSearchAttributes.WantDirectory))
            {
                writer.WriteAttributeString("Type", "directory");
            }

            writer.WriteEndElement();
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:31,代码来源:WixComponentSearchInfo.cs

示例11: BuildEmptyLayout

        protected virtual string BuildEmptyLayout([NotNull] Database database)
        {
            var writer = new StringWriter();
            var output = new XmlTextWriter(writer)
            {
                Formatting = Formatting.Indented
            };

            output.WriteStartElement("Layout");
            output.WriteAttributeString("xmlns", "http://www.sitecore.net/pathfinder/item");

            var deviceItem = database.GetItem(ItemIDs.DevicesRoot);
            if (deviceItem != null)
            {
                foreach (Item item in deviceItem.Children)
                {
                    output.WriteStartElement("Device");
                    output.WriteAttributeString("Name", item.Name);
                    output.WriteEndElement();
                }
            }

            output.WriteEndElement();

            return writer.ToString();
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:26,代码来源:LayoutBuilder2.cs

示例12: CreateSalesReport

        public static void CreateSalesReport()
        {
            SupermarketEntities supermarkets = new SupermarketEntities();

            var queryResult =
                from vendor in supermarkets.Vendors
                select new
                {
                    Vendor = vendor.VendorName,

                    dayToDayReprots =
                        from sale in supermarkets.Sales
                        join product in supermarkets.Products
                        on sale.ProductId equals product.ProductId
                        join report in supermarkets.Reports
                        on sale.ReportId equals report.ReportId
                        where product.VendorId == vendor.VendorId
                        group sale by report.ReportDate
                            into reportForDate
                            select new
                            {
                                Date = reportForDate.Key,
                                TotalSum = reportForDate.Sum(p => p.ProductTotalSum)
                            }
                };

            string fileName = "../../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");

                foreach (var vendor in queryResult)
                {
                    Console.WriteLine("Writing report for " + vendor.Vendor);

                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", vendor.Vendor);

                    foreach (var dayReport in vendor.dayToDayReprots)
                    {
                        writer.WriteStartElement("summary");
                        string dateString = string.Format("{0:dd-MMM-yyyy}", dayReport.Date);
                        writer.WriteAttributeString("date", dateString);
                        writer.WriteAttributeString("total-sum", dayReport.TotalSum.ToString("N2"));
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                     
                }

                writer.WriteEndDocument();
            }
        }
开发者ID:charmisejani,项目名称:TelerikAcademy,代码行数:60,代码来源:Reporter.cs

示例13: ToString

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var s = new StringWriter(new StringBuilder(), CultureInfo.CurrentCulture);
            var xmlWrite = new XmlTextWriter(s);

            xmlWrite.WriteStartDocument();
            xmlWrite.WriteStartElement("userInfo");
            xmlWrite.WriteAttributeString("xmlns", "http://schemas.microsoft.com/office/Outlook/2006/OMS/serviceInfo");

            xmlWrite.WriteStartElement("error");
            xmlWrite.WriteAttributeString("code", this.Code.ToString());

            if (this.Severity != SeverityType.Unknow)
            {
                xmlWrite.WriteAttributeString("severity", this.Severity.ToString());
            }
            xmlWrite.WriteEndElement();

            if (this.Code == ErrorCode.Ok)
            {
                if (!string.IsNullOrEmpty(this.ReplyPhone))
                {
                    xmlWrite.WriteElementString("replyPhone", this.ReplyPhone);
                }
                if (!string.IsNullOrEmpty(this.ReplyPhone))
                {
                    xmlWrite.WriteElementString("smtpAddress", this.SmtpAddress);
                }
            }

            xmlWrite.WriteEndElement();
            xmlWrite.WriteEndDocument();
            return s.GetStringBuilder().ToString();
        }
开发者ID:chenchunwei,项目名称:NPC,代码行数:38,代码来源:OmsUserInfo.cs

示例14: AddHeaderInformation

        public static void AddHeaderInformation(XmlDocument xmlDoc, QMaker qMaker)
        {
            StringBuilder sbH = new StringBuilder();
            StringWriter tempWriterH = new StringWriter(sbH);
            XmlTextWriter writerH = new XmlTextWriter(tempWriterH);

            writerH.WriteStartElement("Headers");

            foreach (QField gField in qMaker.Groups)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", gField.Name);
                writerH.WriteAttributeString("Description", gField.FriendlyName);
                writerH.WriteEndElement();//Header
            }
            foreach (QField fField in qMaker.Fields)
            {
                writerH.WriteStartElement("Header");
                writerH.WriteAttributeString("Name", fField.Name);
                writerH.WriteAttributeString("Description", fField.FriendlyName);
                writerH.WriteEndElement();//Header
            }

            writerH.WriteEndElement();//Headers
            writerH.Flush();

            XmlDocumentFragment xmlHeaders = xmlDoc.CreateDocumentFragment();
            xmlHeaders.InnerXml = sbH.ToString();

            xmlDoc.SelectSingleNode("Report").AppendChild(xmlHeaders);
        }
开发者ID:0anion0,项目名称:IBN,代码行数:31,代码来源:QMetaLoader.cs

示例15: Save_XML

 public void Save_XML(string path)
 {
     XmlTextWriter xmlTextWriter = new XmlTextWriter(path, null);
     xmlTextWriter.Formatting = Formatting.Indented;
     xmlTextWriter.WriteStartDocument(false);
     xmlTextWriter.WriteComment("Xml from Juan converter");
     xmlTextWriter.WriteStartElement("STB");
     for (int num = 0; num != this.rowcount; num++)
     {
         xmlTextWriter.WriteStartElement("Entry");
         xmlTextWriter.WriteAttributeString("id", num.ToString());
         for (int num2 = 0; num2 != this.columncount; num2++)
         {
             if (this.column[num2].selected)
             {
                 xmlTextWriter.WriteStartElement("Data");
                 xmlTextWriter.WriteAttributeString("type", this.column[num2].columntitle);
                 xmlTextWriter.WriteString(this.celldata[num, num2]);
                 xmlTextWriter.WriteEndElement();
             }
         }
         xmlTextWriter.WriteEndElement();
     }
     xmlTextWriter.WriteEndElement();
     xmlTextWriter.Flush();
     xmlTextWriter.Close();
     xmlTextWriter.Close();
 }
开发者ID:Jiwan,项目名称:ROSE-Dev-Workshop,代码行数:28,代码来源:Converter.cs


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