public static void XmlGen()
        {
            var outputFilePath = new DirectoryInfo(
                Environment.GetFolderPath(Environment.SpecialFolder.Desktop)).FullName +
                                 $@"\XmlGenTest6.xml";

            var outputFileInfo = new FileInfo(outputFilePath);

            using var consoleStreamWriter = new ConsoleStreamWriter(
                      outputFileInfo.FullName, false);

            var writer = new XmlStreamWriter(consoleStreamWriter);

            writer.WithDeclaration(FXDeclaration.Get(_xmlVersion, "utf-8"))
            .WithNamespace(excerptNs)
            .WithNamespace(contentNs)
            .WithNamespace(wfwNs)
            .WithNamespace(dcNs)
            .WithNamespace(wpNs);

            writer.WriteStartElement("rss")
            .WriteStartElement("channel")
            .WriteInlineElement(wpNs, "wxr_version", $"{_wxrVersion:0.0}");

            foreach (var tag in WPTerm.AllTags)
            {
                tag.WriteToXmlStream(writer);
            }

            foreach (var category in WPCategory.AllCategories)
            {
                category.WriteToXmlStream(writer);
            }

            foreach (var category in WPCategory.AllCategories)
            {
                writer.WriteStartElement(wpNs, "category")
                .WriteInlineCDataElement(wpNs, "cat_name", category.CategoryName)
                .WriteInlineCDataElement(wpNs, "category_nicename", category.CategoryNiceName)
                .WriteInlineElement(wpNs, "category_parent", "0")
                .WriteEndElement();
            }

            writer.WriteEndElement()
            .WriteEndElement();
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public void WriteToXmlStream(
            XmlStreamWriter writer)
        {
            var wpNs = FXNsRef.FromName("wp");

            var commentDateStr    = CommentDate.ToString("yyyy-MM-dd HH:mm:ss");
            var gmtCommentDateStr = CommentDateGMT.ToString("yyyy-MM-dd HH:mm:ss");

            writer.WriteStartElement(wpNs, "comment")
            .WriteInlineElement(wpNs, "comment_id", CommentId.ToString())
            .WriteInlineElement(wpNs, "comment_approved", "1")
            .WriteInlineElement(wpNs, "comment_author_email", AuthorEmail)
            .WriteInlineCDataElement(wpNs, "comment_author", Author)
            .WriteInlineElement(wpNs, "comment_author_url", "")
            .WriteInlineElement(wpNs, "comment_author_IP", AuthorIP)
            .WriteInlineElement(wpNs, "comment_date", commentDateStr)
            .WriteInlineElement(wpNs, "comment_date_gmt", gmtCommentDateStr)
            .WriteInlineCDataElement(wpNs, "comment_content", Content)
            .WriteInlineElement(wpNs, "comment_type", "")
            .WriteInlineElement(wpNs, "comment_parent", ParentId.ToString());

            writer.WriteEndElement();
        }