private static ISyndicationContent ReadSyndicationContent(XmlReader reader) { string type = null; var content = new SyndicationContent(reader.LocalName, reader.NamespaceURI, null); // // Attributes if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { ISyndicationAttribute attr = reader.ReadSyndicationAttribute(); if (attr != null) { if (type == null && attr.IsAtom(AtomConstants.Type)) { type = attr.Value; } content.AddAttribute(attr); } } reader.MoveToContent(); } // // Content if (!reader.IsEmptyElement) { // // Xml (applies to <content>) if (XmlUtils.IsXmlMediaType(type) && content.IsAtom(AtomElementNames.Content)) { if (reader.NodeType != XmlNodeType.Element) { throw new FormatException($"Invalid Xml element"); } content.Value = reader.ReadInnerXml(); } else { reader.ReadStartElement(); // // Xhtml if (XmlUtils.IsXhtmlMediaType(type) && content.IsAtom()) { if (reader.NamespaceURI != AtomConstants.XhtmlNamespace) { throw new FormatException($"Invalid Xhtml namespace"); } content.Value = reader.ReadInnerXml(); } // // Text/Html else if (reader.HasValue) { content.Value = reader.ReadContentAsString(); } // // Children else { while (reader.IsStartElement()) { content.AddField(ReadSyndicationContent(reader)); } } reader.ReadEndElement(); // end } } else { reader.Skip(); } return(content); }