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


C# System.Xml.XmlTextWriter.WriteElementString方法代码示例

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


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

示例1: CriarArquivoXML

        /// <summary>
        /// Método para criação do Arquivo XML com Configurações do usuário.
        /// </summary>
        public static void CriarArquivoXML()
        {
            try
            {
                System.Xml.XmlTextWriter xtrPrefs = new System.Xml.XmlTextWriter(Directories.UserPrefsDirectory + 
                    @"\UserPrefs.config", System.Text.Encoding.UTF8);

                // Inicia o documento XML.
                xtrPrefs.WriteStartDocument();

                // Escreve elemento raiz.
                xtrPrefs.WriteStartElement("Directories");
                // Escreve sub-Elementos.
                xtrPrefs.WriteElementString("Starbound", Directories.StarboundDirectory);
                xtrPrefs.WriteElementString("Mods", Directories.ModsDirectory);
                // Encerra o elemento raiz.
                xtrPrefs.WriteEndElement();
                // Escreve o XML para o arquivo e fecha o objeto escritor.
                xtrPrefs.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);

            }
        }
开发者ID:MiCLeal,项目名称:Mod-Editor--Starbound,代码行数:29,代码来源:XmlPrefs.cs

示例2: WriteConfig

 // Lecture de la configuration
 public static void WriteConfig()
 {
     string config_file = "config.xml";
     var newconf = new System.Xml.XmlTextWriter(config_file, null);
     newconf.WriteStartDocument();
     newconf.WriteStartElement("config");
     newconf.WriteElementString("last_update", LastUpdate.ToShortDateString());
     newconf.WriteElementString("auth_token", AuthToken);
     newconf.WriteEndElement();
     newconf.WriteEndDocument();
     newconf.Close();
 }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:13,代码来源:Program.cs

示例3: ReadConfig

        // Lecture de la configuration
        static void ReadConfig()
        {
            string config_file = "config.xml";
            if (!System.IO.File.Exists(config_file))
            {
                var newconf = new System.Xml.XmlTextWriter(config_file, null);
                newconf.WriteStartDocument();
                newconf.WriteStartElement("config");
                newconf.WriteElementString("last_update", "0");
                newconf.WriteElementString("auth_token", "");
                newconf.WriteEndElement();
                newconf.WriteEndDocument();
                newconf.Close();
            }

            var conf = new System.Xml.XmlTextReader(config_file);
            string CurrentElement = "";
            while (conf.Read())
            {
                switch(conf.NodeType) {
                    case System.Xml.XmlNodeType.Element:
                        CurrentElement = conf.Name;
                        break;
                    case System.Xml.XmlNodeType.Text:
                    if (CurrentElement == "last_update")
                        LastUpdate = DateTime.Parse(conf.Value);
                    if (CurrentElement == "auth_token")
                        AuthToken = conf.Value;
                        break;
                }
            }
            conf.Close();

            // On vérifie que le token est encore valide
            if (AuthToken.Length > 0)
            {
                var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
                try
                {
                    Auth auth = flickr.AuthCheckToken(AuthToken);
                    Username = auth.User.UserName;
                }
                catch (FlickrApiException ex)
                {
                    //MessageBox.Show(ex.Message, "Authentification requise",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    AuthToken = "";
                }
            }
        }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:51,代码来源:Program.cs

示例4: GenerateNotificationContent

        /// <summary>
        /// Generates the content of the notification.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static string GenerateNotificationContent(string template, Dictionary<string, object> data)
        {
            using(var writer = new System.IO.StringWriter())
            {
                using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
                {
                    xml.WriteStartElement("root");

                    foreach (DictionaryEntry de in HostSettingManager.GetHostSettings())
                        xml.WriteElementString(string.Concat("HostSetting_", de.Key), de.Value.ToString());

                    foreach (var item in data.Keys)
                    {
                        if (item.StartsWith("RawXml"))
                        {
                            xml.WriteRaw(data[item].ToString());
                        }
                        else if (item.GetType().IsClass)
                        {
                            xml.WriteRaw(data[item].ToXml());
                        }
                        else
                        {
                            xml.WriteElementString(item, data[item].ToString());
                        }
                    }

                    xml.WriteEndElement();

                    return XmlXslTransform.Transform(writer.ToString(), template);
                }
            }
        }
开发者ID:chad247,项目名称:bugnet,代码行数:39,代码来源:NotificationManager.cs

示例5: SaveQuotes

        /// <summary>
        /// Saves movie quotes to an xml file 
        /// </summary>
        /// <param name="movie">IIMDbMovie object</param>
        /// <param name="xmlPath">path to save xml file to</param>
        /// <param name="overwrite">set to true to overwrite existing xml file</param>
        public static void SaveQuotes(
            IIMDbMovie movie, 
            string xmlPath, 
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Quotes.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default)
                                    {Formatting = System.Xml.Formatting.Indented};

                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Quotes");
                        foreach (IList<IIMDbQuote> quoteBlock in movie.Quotes)
                        {
                            xmlWr.WriteStartElement("QuoteBlock");
                            foreach (IIMDbQuote quote in quoteBlock)
                            {
                                xmlWr.WriteStartElement("Quote");
                                xmlWr.WriteElementString("Character", quote.Character);
                                xmlWr.WriteElementString("QuoteText", quote.Text);
                                xmlWr.WriteEndElement();
                            }
                            xmlWr.WriteEndElement();
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:47,代码来源:ExtraFilmDetailsFileIO.cs

示例6: GenerateNotificationContent

        /// <summary>
        /// Generates the content of the notification.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static string GenerateNotificationContent(string template, Dictionary<string, object> data)
        {
            using(var writer = new System.IO.StringWriter())
            {
                using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
                {
                    xml.WriteStartElement("root");

                    foreach (var de in HostSettingManager.GetHostSettings().Cast<DictionaryEntry>().Where(de => !de.Key.ToString().ToLower().Equals("welcomemessage")))
                    {
                        xml.WriteElementString(string.Concat("HostSetting_", de.Key), de.Value.ToString());
                    }

                    foreach (var item in data.Keys)
                    {
                        if (item.StartsWith("RawXml"))
                        {
                            xml.WriteRaw(data[item].ToString());
                        }
                        else if (item.GetType().IsClass)
                        {
                            xml.WriteRaw(data[item].ToXml());
                        }
                        else
                        {
                            xml.WriteElementString(item, data[item].ToString());
                        }
                    }

                    xml.WriteEndElement();
#if(DEBUG)
                    System.Diagnostics.Debug.WriteLine(writer.ToString()); 
#endif
                    return XmlXslTransform.Transform(writer.ToString(), template);
                }   
            }
        }
开发者ID:ChuckLafferty,项目名称:bugnet,代码行数:43,代码来源:NotificationManager.cs

示例7: SaveGoofs

        /// <summary>
        /// Saves movie goofs to an xml file 
        /// </summary>
        /// <param name="movie">IIMDbMovie object</param>
        /// <param name="xmlPath">path to save xml file to</param>
        /// <param name="overwrite">set to true to overwrite existing xml file</param>
        public void SaveGoofs(
            IIMDbMovie movie,
            string xmlPath,
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (System.IO.File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Goofs.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default);
                        xmlWr.Formatting = System.Xml.Formatting.Indented;
                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Goofs");
                        foreach (IIMDbGoof goof in movie.Goofs)
                        {
                            xmlWr.WriteStartElement("Goof");
                            xmlWr.WriteElementString("Category", goof.Category);
                            xmlWr.WriteElementString("Description", goof.Description);
                            xmlWr.WriteEndElement();
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                        xmlWr = null;
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:stavrossk,项目名称:Disc_Archiver_for_Meedio,代码行数:42,代码来源:IMDbLib.cs

示例8: writeGPX

        public void writeGPX(string filename)
        {
            System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII);

            xw.WriteStartElement("gpx");
            xw.WriteAttributeString("creator", MainV2.instance.Text);
            xw.WriteAttributeString("xmlns", "http://www.topografix.com/GPX/1/1");

            xw.WriteStartElement("trk");

            xw.WriteStartElement("trkseg");

            DateTime start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

            foreach (Data mod in flightdata)
            {
                xw.WriteStartElement("trkpt");
                xw.WriteAttributeString("lat", mod.model.Location.latitude.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", mod.model.Location.longitude.ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("ele", mod.model.Location.altitude.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("time", mod.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"));
                xw.WriteElementString("course", (mod.model.Orientation.heading).ToString(new System.Globalization.CultureInfo("en-US")));

                xw.WriteElementString("roll", mod.model.Orientation.roll.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("pitch", mod.model.Orientation.tilt.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("mode", mod.mode);

                //xw.WriteElementString("speed", mod.model.Orientation.);
                //xw.WriteElementString("fix", mod.model.Location.altitude);

                xw.WriteEndElement();
            }


            xw.WriteEndElement(); // trkseg
            xw.WriteEndElement(); // trk

            int a = 0;
            foreach (Data mod in flightdata)
            {
                xw.WriteStartElement("wpt");
                xw.WriteAttributeString("lat", mod.model.Location.latitude.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteAttributeString("lon", mod.model.Location.longitude.ToString(new System.Globalization.CultureInfo("en-US")));
                xw.WriteElementString("name", (a++).ToString());
                xw.WriteEndElement();//wpt
            }

            xw.WriteEndElement(); // gpx

            xw.Close();
        }
开发者ID:Event38,项目名称:MissionPlanner,代码行数:52,代码来源:LogOutput.cs

示例9: WriteAccounts

        public void WriteAccounts()
        {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter (xml_path, System.Text.Encoding.Default);

            writer.Formatting = System.Xml.Formatting.Indented;
            writer.Indentation = 2;
            writer.IndentChar = ' ';

            writer.WriteStartDocument (true);

            writer.WriteStartElement ("GalleryRemote");
            foreach (GalleryAccount account in accounts) {
                writer.WriteStartElement ("Account");
                writer.WriteElementString ("Name", account.Name);

                writer.WriteElementString ("Url", account.Url);
                writer.WriteElementString ("Username", account.Username);
                writer.WriteElementString ("Password", account.Password);
                writer.WriteElementString ("Version", account.Version.ToString());
                writer.WriteEndElement (); //Account
            }
            writer.WriteEndElement ();
            writer.WriteEndDocument ();
            writer.Close ();
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:25,代码来源:GalleryAccountManager.cs

示例10: PublishRSS

        /// <summary>
        /// Create RSSRoot and write it to stream.
        /// </summary>
        /// <param name="rSSRoot"></param>
        /// <returns></returns>
        public static bool PublishRSS(RSSRoot rSSRoot)
        {
            bool blnResult = true;

            if(rSSRoot == null)
                return(false);

            if(rSSRoot.Channel == null)
                return(false);

            System.Xml.XmlTextWriter oXmlTextWriter = new System.Xml.XmlTextWriter(rSSRoot.OutputStream, System.Text.Encoding.UTF8);

            oXmlTextWriter.WriteStartDocument();

            oXmlTextWriter.WriteStartElement("rss");
            oXmlTextWriter.WriteAttributeString("version", "2.0");

            oXmlTextWriter.WriteStartElement("channel");

            oXmlTextWriter.WriteElementString("link", rSSRoot.Channel.Link);
            oXmlTextWriter.WriteElementString("title", rSSRoot.Channel.Title);
            oXmlTextWriter.WriteElementString("description", rSSRoot.Channel.Description);

            if(rSSRoot.Channel.Docs != "")
                oXmlTextWriter.WriteElementString("docs", rSSRoot.Channel.Docs);

            if(rSSRoot.Channel.PubDate != "")
            {
                System.DateTime sDateTime = System.Convert.ToDateTime(rSSRoot.Channel.PubDate);
                oXmlTextWriter.WriteElementString("pubDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
            }

            if(rSSRoot.Channel.Generator != "")
                oXmlTextWriter.WriteElementString("generator", rSSRoot.Channel.Generator);

            if(rSSRoot.Channel.WebMaster != "")
                oXmlTextWriter.WriteElementString("webMaster", rSSRoot.Channel.WebMaster);

            if(rSSRoot.Channel.Copyright != "")
                oXmlTextWriter.WriteElementString("copyright", rSSRoot.Channel.Copyright);

            if(rSSRoot.Channel.LastBuildDate != "")
            {
                System.DateTime sDateTime = System.Convert.ToDateTime(rSSRoot.Channel.LastBuildDate);
                oXmlTextWriter.WriteElementString("lastBuildDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
            }

            if(rSSRoot.Channel.ManagingEditor != "")
                oXmlTextWriter.WriteElementString("managingEditor", rSSRoot.Channel.ManagingEditor);

            oXmlTextWriter.WriteElementString("language", rSSRoot.Channel.Language.ToString().Replace("_", "-"));

            if(rSSRoot.Image != null)
            {
                oXmlTextWriter.WriteStartElement("image");

                oXmlTextWriter.WriteElementString("url", rSSRoot.Image.URL);
                oXmlTextWriter.WriteElementString("link", rSSRoot.Image.Link);
                oXmlTextWriter.WriteElementString("title", rSSRoot.Image.Title);

                if(rSSRoot.Image.Description != "")
                    oXmlTextWriter.WriteElementString("description", rSSRoot.Image.Description);

                if(rSSRoot.Image.Width != 0)
                    oXmlTextWriter.WriteElementString("width", rSSRoot.Image.Width.ToString());

                if(rSSRoot.Image.Height != 0)
                    oXmlTextWriter.WriteElementString("height", rSSRoot.Image.Height.ToString());

                oXmlTextWriter.WriteEndElement();
            }

            foreach(RSSItem itmCurrent in rSSRoot.Items)
            {
                oXmlTextWriter.WriteStartElement("item");

                if(itmCurrent.Link != "")
                    oXmlTextWriter.WriteElementString("link", itmCurrent.Link);

                if(itmCurrent.Title != "")
                    oXmlTextWriter.WriteElementString("title", itmCurrent.Title);

                if(itmCurrent.Author != "")
                    oXmlTextWriter.WriteElementString("author", itmCurrent.Author);

                if(itmCurrent.PubDate != "")
                {
                    System.DateTime sDateTime = System.Convert.ToDateTime(itmCurrent.PubDate);
                    oXmlTextWriter.WriteElementString("pubDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
                }

                if(itmCurrent.Comment != "")
                    oXmlTextWriter.WriteElementString("comment", itmCurrent.Comment);

                if(itmCurrent.Description != "")
//.........这里部分代码省略.........
开发者ID:bietiekay,项目名称:YAPS,代码行数:101,代码来源:RSSUtilities.cs

示例11: saveConfiguration

 void saveConfiguration()
 {
     using (var cfg = new System.Xml.XmlTextWriter(ConfigFile, Encoding.UTF8))
     {
         cfg.Formatting = System.Xml.Formatting.Indented;
         cfg.WriteStartDocument();
         cfg.WriteStartElement("SporeMasterConfig");
         cfg.WriteStartElement("Packages");
         foreach (var p in PackageList.Items)
             cfg.WriteElementString("Package", (p as ListBoxItem).Content as string);
         cfg.WriteEndElement();
         cfg.WriteStartElement("FullTextIndexExtensions");
         foreach (var ext in FilesEditor.fullTextExtensions)
             cfg.WriteElementString("Extension", ext);
         cfg.WriteEndElement();
         cfg.WriteElementString("WinMerge", FilesEditor.WinMergeEXE);
         cfg.WriteElementString("UnpackedFolderFormat", UnpackedFolderFormat);
         cfg.WriteEndElement();
         cfg.WriteEndDocument();
     }
 }
开发者ID:VFedyk,项目名称:sporemaster,代码行数:21,代码来源:MainWindow.xaml.cs

示例12: SaveResultsAsXML

        /// <summary>
        /// Save results to a xml file
        /// </summary>
        /// <param name="path">Fully qualified file path</param>
        /// <history>
        /// [Curtis_Beard]		09/06/2006	Created
        /// </history>
        private void SaveResultsAsXML(string path)
        {
            System.Xml.XmlTextWriter writer = null;

             try
             {
            stbStatus.Text = string.Format(Language.GetGenericText("SaveSaving"), path);

            // Open the file
            writer = new System.Xml.XmlTextWriter(path, System.Text.Encoding.UTF8);
            writer.Formatting = System.Xml.Formatting.Indented;

            writer.WriteStartDocument(true);
            writer.WriteStartElement("astrogrep");
            writer.WriteAttributeString("version", "1.0");

            // write out search options
            writer.WriteStartElement("options");
            writer.WriteElementString("searchPath", __Grep.StartDirectory);
            writer.WriteElementString("fileTypes", __Grep.FileFilter);
            writer.WriteElementString("searchText", __Grep.SearchText);
            writer.WriteElementString("regularExpressions", __Grep.UseRegularExpressions.ToString());
            writer.WriteElementString("caseSensitive", __Grep.UseCaseSensitivity.ToString());
            writer.WriteElementString("wholeWord", __Grep.UseWholeWordMatching.ToString());
            writer.WriteElementString("recurse", __Grep.UseRecursion.ToString());
            writer.WriteElementString("showFileNamesOnly", __Grep.ReturnOnlyFileNames.ToString());
            writer.WriteElementString("negation", __Grep.UseNegation.ToString());
            writer.WriteElementString("lineNumbers", __Grep.IncludeLineNumbers.ToString());
            writer.WriteElementString("contextLines", __Grep.ContextLines.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("search");
            writer.WriteAttributeString("totalfiles", __Grep.Greps.Count.ToString());

            // get total hits
            int totalHits = 0;
            for (int _index = 0; _index < lstFileNames.Items.Count; _index++)
            {
               HitObject _hit = __Grep.RetrieveHitObject(int.Parse(lstFileNames.Items[_index].SubItems[Constants.COLUMN_INDEX_GREP_INDEX].Text));

               // add to total
               totalHits += _hit.HitCount;

               // clear hit object
               _hit = null;
            }
            writer.WriteAttributeString("totalfound", totalHits.ToString());

            for (int _index = 0; _index < lstFileNames.Items.Count; _index++)
            {
               writer.WriteStartElement("item");
               HitObject _hit = __Grep.RetrieveHitObject(int.Parse(lstFileNames.Items[_index].SubItems[Constants.COLUMN_INDEX_GREP_INDEX].Text));

               writer.WriteAttributeString("file", _hit.FilePath);
               writer.WriteAttributeString("total", _hit.HitCount.ToString());

               // write out lines
               for (int _jIndex = 0; _jIndex < _hit.LineCount; _jIndex++)
                  writer.WriteElementString("line", _hit.RetrieveLine(_jIndex));

               // clear hit object
               _hit = null;

               writer.WriteEndElement();
            }

            writer.WriteEndElement();   //search
            writer.WriteEndElement();   //astrogrep
             }
             catch (Exception ex)
             {
            MessageBox.Show(string.Format(Language.GetGenericText("SaveError"), ex.ToString()), Constants.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             finally
             {
            // Close file
            if (writer != null)
            {
               writer.Flush();
               writer.Close();
            }

            stbStatus.Text = Language.GetGenericText("SaveSaved");
             }
        }
开发者ID:joshball,项目名称:astrogrep,代码行数:92,代码来源:frmMain.cs

示例13: CreatePlayList

 public byte[] CreatePlayList(Uri baseuri, IEnumerable<KeyValuePair<string,string>> parameters)
 {
   var queries = String.Join("&", parameters.Select(kv => Uri.EscapeDataString(kv.Key) + "=" + Uri.EscapeDataString(kv.Value)));
   var stream = new System.IO.StringWriter();
   var xml = new System.Xml.XmlTextWriter(stream);
   xml.Formatting = System.Xml.Formatting.Indented;
   xml.WriteStartElement("ASX");
   xml.WriteAttributeString("version", "3.0");
   if (Channels.Count>0) {
     xml.WriteElementString("Title", Channels[0].ChannelInfo.Name);
   }
   foreach (var c in Channels) {
     string name = c.ChannelInfo.Name;
     string contact_url = null;
     if (c.ChannelInfo.URL!=null) {
       contact_url = c.ChannelInfo.URL;
     }
     var stream_url = new UriBuilder(baseuri);
     stream_url.Scheme = "mms";
     if (stream_url.Path[stream_url.Path.Length-1]!='/') {
       stream_url.Path += '/';
     }
     stream_url.Path +=
       c.ChannelID.ToString("N").ToUpper() +
       c.ChannelInfo.ContentExtension;
     if (queries!="") {
       stream_url.Query = queries;
     }
     xml.WriteStartElement("Entry");
     xml.WriteElementString("Title", name);
     if (contact_url!=null && contact_url!="") {
       xml.WriteStartElement("MoreInfo");
       xml.WriteAttributeString("href", contact_url);
       xml.WriteEndElement();
     }
     xml.WriteStartElement("Ref");
     xml.WriteAttributeString("href", stream_url.Uri.ToString());
     xml.WriteEndElement();
     xml.WriteEndElement();
   }
   xml.WriteEndElement();
   xml.Close();
   var res = stream.ToString();
   try {
     return System.Text.Encoding.GetEncoding(932).GetBytes(res);
   }
   catch (System.Text.EncoderFallbackException) {
     return System.Text.Encoding.UTF8.GetBytes(res);
   }
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:50,代码来源:PlayList.cs

示例14: SaveTrivia

        /// <summary>
        /// Saves movie trivia to an xml file 
        /// </summary>
        /// <param name="movie">IIMDbMovie object</param>
        /// <param name="xmlPath">path to save xml file to</param>
        /// <param name="overwrite">set to true to overwrite existing xml file</param>
        public void SaveTrivia(
            IIMDbMovie movie,
            string xmlPath,
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (System.IO.File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Trivia.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default);
                        xmlWr.Formatting = System.Xml.Formatting.Indented;
                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Trivias");
                        foreach (string trivia in movie.Trivia)
                        {
                            xmlWr.WriteElementString("Trivia", trivia);
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                        xmlWr = null;
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:stavrossk,项目名称:Disc_Archiver_for_Meedio,代码行数:39,代码来源:IMDbLib.cs

示例15: SaveConfigurations

        public static void SaveConfigurations()
        {
            //serialize the old fashioned way (because I can't serialize it using the normal way because that would pick up all the properties from the Microsoft base classes)
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(projectManager.GetSelectedProjectNode().FullPath + ".bidsHelper.user", Encoding.ASCII);
            writer.Formatting = System.Xml.Formatting.Indented;
            writer.WriteStartElement("Configurations");
            foreach (IProjectConfiguration config in ConfigurationManager.Configurations)
            {
                DtsProjectExtendedConfigurationOptions options = config.Options as DtsProjectExtendedConfigurationOptions;
                if (options != null)
                {
                    writer.WriteStartElement("Configuration");
                    writer.WriteElementString("Name", config.DisplayName);
                    writer.WriteStartElement("Options");
                    writer.WriteElementString("DeploymentType", options.DeploymentType.ToString());
                    writer.WriteElementString("FilePath", options.FilePath);
                    writer.WriteElementString("DestinationServer", options.DestinationServer);
                    writer.WriteElementString("DestinationFolder", options.DestinationFolder);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
            writer.Close();

            //mark project file as dirty
            projectManager.GetType().InvokeMember("MarkTextBufferAsUnsaved", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.InvokeMethod, null, projectManager, new object[] { });
        }
开发者ID:japj,项目名称:bidshelper,代码行数:28,代码来源:DeployPackagesPlugin.cs


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