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


C# XDocument.WriteTo方法代码示例

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


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

示例1: Export

        public ActionResult Export() {
            var content = _contentManager
                .Query(VersionOptions.Published)
                .List();

            XDocument export = new XDocument();
            export.Add(new XElement("Orchard"));
            export.Element("Orchard").Add(new XElement("Data"));
            foreach(var contentItem in content) {
                export.Element("Orchard").Element("Data").Add(_contentManager.Export(contentItem));
            }

            StringBuilder xml = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings()
                {Encoding = Encoding.UTF8, Indent = true, NewLineHandling = NewLineHandling.Entitize, NewLineOnAttributes = true};
            using (XmlWriter w = XmlWriter.Create(xml, settings)) {
                export.WriteTo(w);
                w.Flush();
            }

            return new ContentResult() {
                Content = xml.ToString(),
                ContentType = "text/xml",
                ContentEncoding = Encoding.UTF8
            };
        }
开发者ID:JustGiving,项目名称:Tad.ContentSync,代码行数:26,代码来源:ContentImportExportController.cs

示例2: WriteCodebook

 public void WriteCodebook(string path, StudyUnitVM studyUnit)
 {
     Debug.Assert(!string.IsNullOrEmpty(path));
     this.studyUnit = studyUnit;
     ClearError();
     CreateConvertIds();
     XmlWriterSettings xws = new XmlWriterSettings();
     xws.Indent = true;
     xws.Encoding = Encoding.UTF8;
     using (XmlWriter xw = XmlWriter.Create(path, xws))
     {
         XDocument doc = new XDocument(
             DECLARATION,
             new XElement(cb + TAG_CODEBOOK,
                 CreateSafeIDAttribute(studyUnit.Id),
                 CreateVersionAttribute(),
                 new XAttribute("xmlns", cb),
                 new XAttribute(XNamespace.Xmlns + "xsi", xsi),
                 new XAttribute(XNamespace.Xmlns + "dc", dc),
                 new XAttribute(XNamespace.Xmlns + "terms", terms),
                 new XAttribute(XNamespace.Xmlns + "schemaLocation", schemaLocation),
                 CreateStdyDscr(),
                 CreateFileDscrs(),
                 CreateDataDscr()
                 )
         );
         CheckError();
         doc.WriteTo(xw);
     }
 }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:30,代码来源:DDI2Writer.cs

示例3: WriteXml

 private static void WriteXml(XDocument xml)
 {
     using (var writer = XmlWriter.Create(Console.Out, new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }))
     {
         xml.WriteTo(writer);
     }
 }
开发者ID:yannduran,项目名称:NuDoq,代码行数:7,代码来源:XmlVisitorFixture.cs

示例4: WriteTo

        public static void WriteTo(BundleEntry entry, XmlWriter writer, bool summary = false)
        {
            if (entry == null) throw new ArgumentException("Entry cannot be null");

            var result = createEntry(entry,summary);

            var doc = new XDocument(result);
            doc.WriteTo(writer);
        }
开发者ID:ranjancse26,项目名称:fhir-net-api,代码行数:9,代码来源:BundleXmlSerializer.cs

示例5: Write

 public void Write(Stream s)
 {
     var metaDataDocument = new XDocument();
     FillMetaDataDocument(metaDataDocument);
     var settings = new XmlWriterSettings {CloseOutput = false, Encoding = Encoding.UTF8, Indent = true};
     using (var writer = XmlWriter.Create(s, settings))
     {
         metaDataDocument.WriteTo(writer);
     }
 }
开发者ID:rajeshwarn,项目名称:fb2converters,代码行数:10,代码来源:ContainerFile.cs

示例6: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/rss+xml";
            XNamespace media = "http://search.yahoo.com/mrss";

            using (var quran = new QuranObjects.QuranContext())
            {
                var translations = (from translation in quran.MyTranslations
                                    orderby translation.LastUpdateDate descending
                                    select translation).Take(25).ToList();

                XDocument rss = new XDocument(
                    new XElement("rss", new XAttribute("version", "2.0"),
                        new XElement("channel",
                            new XElement("title", "Quran Modern Bangla Translation Updates"),
                            new XElement("link", "http://quran.omaralzabir.com"),
                            new XElement("description", ""),
                            new XElement("language", ""),
                            new XElement("pubDate", DateTime.Now.ToString("r")),
                            new XElement("generator", "XLinq"),

                            from mytranslation in translations
                            select new XElement("item",
                                       new XElement("title", (mytranslation.CreatedDate == mytranslation.LastUpdateDate ? "Add: " : "Update: ") + mytranslation.SurahNo + ":" + mytranslation.AyahNo),
                                       new XElement("link", "http://quran.omaralzabir.com/" + mytranslation.SurahNo + "/" + mytranslation.AyahNo,
                                           new XAttribute("rel", "alternate"),
                                           new XAttribute("type", "text/html"),
                                           new XAttribute("href", "http://quran.omaralzabir.com/" + mytranslation.SurahNo + "/" + mytranslation.AyahNo)),
                                       new XElement("id", mytranslation.ID.ToString() + mytranslation.LastUpdateDate.Ticks.ToString()),
                                       new XElement("pubDate", mytranslation.LastUpdateDate.ToLongDateString()),
                                       new XElement("description",
                                           new XCData(
                                               string.Format("<h2>{0}</h2><p style=\"font-size: 16pt\">{1}</p><p style=\"font-size: 14pt\">{2}</p><p><hr /></p>", mytranslation.Heading, mytranslation.Translation, mytranslation.Footnote) +
                                               string.Join("",
                                                   (from translation in quran.Ayahs
                                                    where translation.SurahNo == mytranslation.SurahNo &&
                                                    translation.AyahNo == mytranslation.AyahNo && translation.Translator.ShowDefault == true
                                                    orderby translation.Translator.Order
                                                    select ("<p style=\"margin:0; padding:0; font: italic 16px/18px georgia;color: #6798BF;display: block;font-size: 10pt;line-height: 18px;margin-left: 10px;\">" + translation.Translator.Name + "</p>" +
                                                    "<p style=\"margin:0; padding:0; font-size: 14pt;font-family: Georgia;text-align: left;line-height: 24px;margin-left: 10px;\">" + translation.Content + "</p>")))
                                           )
                                       ),
                                       new XElement("author", "Omar AL Zabir")
                                  )
                             )
                        )
                    );
                using (XmlWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
                {
                    rss.WriteTo(writer);
                }
            }
        }
开发者ID:cometofsky,项目名称:Quran,代码行数:53,代码来源:Rss.ashx.cs

示例7: Write

        /// <summary>
        /// Writes content to stream
        /// </summary>
        /// <param name="s"></param>
        public void Write(Stream s)
        {
            var contentDocument = new XDocument();
            CreateNAVDocument(contentDocument);
            var settings = new XmlWriterSettings {CloseOutput = false, Encoding = Encoding.UTF8, Indent = true};
            using (var writer = XmlWriter.Create(s, settings))
            {
                contentDocument.WriteTo(writer);
            }


        }
开发者ID:npuBug,项目名称:epublibrary,代码行数:16,代码来源:NavigationDocumentFile.cs

示例8: EstimateSize

 /// <summary>
 /// Extends IHTMLItem class to evaluate the size of generated output
 /// </summary>
 /// <param name="item">item to evaluate</param>
 /// <returns></returns>
 public static ulong EstimateSize(this IHTMLItem item)
 {
     var stream = new MemoryStream();
     var node = item.Generate();
     var doc = new XDocument();
     doc.Add(node);
     using (var writer = XmlWriter.Create(stream))
     {
         doc.WriteTo(writer);
     }
     return (ulong)stream.Length;
 }
开发者ID:npuBug,项目名称:fb2epub,代码行数:17,代码来源:XhtmlItemExtender.cs

示例9: Xml

        public object Xml(XDocument document)
        {
            // This is a JSON based web service, ya jerk!
            MemoryStream ms = new MemoryStream();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using(XmlWriter writer = XmlWriter.Create(ms, settings))
            {
                document.WriteTo(writer);
            }
            return Resource(ms, "text/xml");
        }
开发者ID:strider-,项目名称:Json-Service,代码行数:13,代码来源:Program.cs

示例10: Write

 public void Write(Stream s)
 {
     XDocument contentDocument = new XDocument();
     CreateContentDocument(contentDocument);
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.CloseOutput = false;
     settings.Encoding = Encoding.Unicode;
     settings.Indent = true;
     using (var writer = XmlWriter.Create(s, settings))
     {
         contentDocument.WriteTo(writer);
     }
 }
开发者ID:rajeshwarn,项目名称:fb2converters,代码行数:13,代码来源:AppleDisplayOptionsFile.cs

示例11: CreateConfigurationXmlStream

        /// <summary>
        /// Creates the configuration XML stream.
        /// </summary>
        /// <param name="configurationXml">The configuration XML.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private static MemoryStream CreateConfigurationXmlStream(XDocument configurationXml)
        {
            MemoryStream ms = new MemoryStream();
            XmlWriterSettings xws = new XmlWriterSettings {OmitXmlDeclaration = true, Indent = true};

            using (XmlWriter xw = XmlWriter.Create(ms, xws))
            {
                configurationXml.WriteTo(xw);
            }

            ms.Position = 0;
            return ms;
        }
开发者ID:neiliux,项目名称:FileStoreArchiver,代码行数:19,代码来源:FsaConfigurationValidator.cs

示例12: XDocument

 public static void XDocument(this HttpResponseBase response, XDocument doc, string contentType)
 {
     if (response == null)
         throw new ArgumentNullException("response");
     if (doc == null)
         throw new ArgumentNullException("doc");
     if (contentType != null)
         response.ContentType = contentType;
     using (var xmlwriter = XmlWriter.Create(response.Output, new XmlWriterSettings { Indent = true })) {
         doc.WriteTo(xmlwriter);
         xmlwriter.Flush();
     }
 }
开发者ID:mausch,项目名称:MiniMVC,代码行数:13,代码来源:Response.cs

示例13: CreateFileIfNotExist

 private static void CreateFileIfNotExist()
 {
     lock (_lockObject)
     {
         if (File.Exists(_path)) return;
         var name = XName.Get("announcements");
         var doc = new XDocument(new XElement(name));
         using (var xmlWriter = XmlWriter.Create(File.CreateText(_path)))
         {
             doc.WriteTo(xmlWriter);
         }
     }
 }
开发者ID:Zjazure,项目名称:FailureTroubleshooting,代码行数:13,代码来源:AnnouncementsStore.cs

示例14: Serialize

        public void Serialize()
        {
            var doc = new XDocument(new XDeclaration("1.0", null, null));

            var elementName = messageType.SerializationFriendlyName();
            doc.Add(new XElement(elementName));
            WriteObject(doc.Root, elementName, messageType, message, true);

            SetDefaultNamespace(doc.Root, $"{@namespace}/{messageType.Namespace}");
            ForceEmptyTagsWithNewlines(doc);

            doc.WriteTo(writer);
            writer.Flush();
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:14,代码来源:XmlSerialization.cs

示例15: Serialize

        public void Serialize(System.IO.Stream Stream, ISerializableObject SerializableObject)
        {
            XDocument xdoc = new XDocument();

            xdoc.Add(new XElement("Root"));

            Serialize(xdoc.Root, SerializableObject);

            System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(Stream, new System.Xml.XmlWriterSettings() { Indent = true });

            xdoc.WriteTo(xmlWriter);

            xmlWriter.Close();
        }
开发者ID:data-avail,项目名称:DataAvail.WinForms,代码行数:14,代码来源:XMLSerializationFormatter.cs


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