/// <summary>
        /// Saves the RDF feed as RDF 1.0.
        /// </summary>
        /// <returns></returns>
        private XmlDocument SerializeToXml_1_0(string encoding)
        {
            XmlDocument xdRdf = new XmlDocument();

            XmlDeclaration xdDeclaration = xdRdf.CreateXmlDeclaration(RDF_XML_VERSION_1_0, encoding, null);

            xdRdf.AppendChild(xdDeclaration);

            //
            // Get Prefix.
            //
            string prefix = (this.Prefix == null) ? RDF_PREFIX_RDF : this.Prefix;

            //
            // Create the rdf element.
            //
            XmlElement xeRdf = xdRdf.CreateElement(prefix, RDF_ELEMENT_RDF, ((this.RdfNamespaceURI != null) ? this.RdfNamespaceURI : RDF_ATTRIBUTE_RDF_VALUE_1_0));

            XmlAttribute xaXmlns = xdRdf.CreateAttribute(RDF_ATTRIBUTE_XMLNS);

            xaXmlns.InnerText = (this.NamespaceURI != null) ? this.NamespaceURI : RDF_ATTRIBUTE_XMLNS_VALUE_1_0;
            xeRdf.Attributes.Append(xaXmlns);

            xdRdf.AppendChild(xeRdf);

            //
            // Append the channel element.
            //
            RdfChannelItems     rci              = (this.Items != null) ? this.Items.GetChannelItems() : null;
            RdfChannelImage     channelImage     = (this.Image != null) ? this.Image.GetChannelImage() : null;
            RdfChannelTextInput channelTextInput = (this.TextInput != null) ? this.TextInput.GetChannelTextInput() : null;

            xeRdf.AppendChild(this.Channel.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, rci, prefix, channelImage, channelTextInput));

            if (this.Image != null)
            {
                xeRdf.AppendChild(this.Image.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }

            this.Items.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, xeRdf, prefix);

            if (this.TextInput != null)
            {
                xeRdf.AppendChild(this.TextInput.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }

            //
            // Return the created XML document.
            //
            return(xdRdf);
        }
Пример #2
0
        /// <summary>
        /// Serializes the object to XML according to RSS 0.91.
        /// </summary>
        /// <param name="xdRss"></param>
        /// <returns></returns>
        private XmlNode SerializeToXml_1_0(XmlDocument xdRdf, RdfChannelItems channelItems, string prefix, RdfChannelImage channelImage, RdfChannelTextInput channelTextInput)
        {
            XmlAttribute xaAbout = xdRdf.CreateAttribute(prefix, RDF_ATTRIBUTE_ABOUT, xdRdf.DocumentElement.NamespaceURI);

            xaAbout.InnerText = this.GetAbout();

            XmlElement xeChannel = xdRdf.CreateElement(null, RDF_ELEMENT_CHANNEL, xdRdf.DocumentElement.Attributes[RDF_ATTRIBUTE_XMLNS].InnerText);

            xeChannel.Attributes.Append(xaAbout);

            if (this.Title != null)
            {
                xeChannel.AppendChild(SerializeTitleToXml(xdRdf));
            }
            if (this.Link != null)
            {
                xeChannel.AppendChild(SerializeLinkToXml(xdRdf));
            }
            if (this.Description != null)
            {
                xeChannel.AppendChild(SerializeDescriptionToXml(xdRdf));
            }
            if (this.Image != null)
            {
                xeChannel.AppendChild(this.Image.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            else if (channelImage != null)
            {
                xeChannel.AppendChild(channelImage.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            if (this.Items != null)
            {
                xeChannel.AppendChild(this.Items.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            else if (channelItems != null)
            {
                xeChannel.AppendChild(channelItems.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            if (this.TextInput != null)
            {
                xeChannel.AppendChild(this.TextInput.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            else if (channelTextInput != null)
            {
                xeChannel.AppendChild(channelTextInput.SerializeToXml(xdRdf, RdfVersion.RDF_1_0, prefix));
            }
            //
            // Always serialize modules last.
            //
            if (this.Modules != null)
            {
                this.Modules.SerializeToXml(xeChannel);
            }
            return(xeChannel);
        }
Пример #3
0
 /// <summary>
 /// Serializes the object to XML.
 /// </summary>
 /// <param name="xdRss"></param>
 /// <param name="elementName"></param>
 /// <param name="rssVersion"></param>
 /// <returns></returns>
 internal XmlNode SerializeToXml(XmlDocument xdRdf, RdfVersion version, RdfChannelItems channelItems, string prefix, RdfChannelImage channelImage, RdfChannelTextInput channelTextInput)
 {
     if (version == RdfVersion.RDF_1_0)
     {
         return(SerializeToXml_1_0(xdRdf, channelItems, prefix, channelImage, channelTextInput));
     }
     throw new ArgumentException(Rdf.RDF_ERRORMESSAGE_UNKNOWN_VALUE, "version");
 }