public void ReadXml(XmlReader reader) { bool isEmpty = reader.IsEmptyElement; AddAttributeExtensions(reader); reader.ReadStartElement(); if (!isEmpty) { while (reader.IsStartElement()) { if (reader.LocalName == MediaRssContent.ELEMENT_NAME) { var contentNode = new MediaRssContent(); contentNode.ReadXml(reader); ContentNodes.Add(contentNode); } else if (MediaRssHelper.TryParseOptionalElement(OptionalElements, reader) == false) ElementExtensions.Add((XElement)XNode.ReadFrom(reader)); } reader.ReadEndElement(); } }
protected override bool TryParseElement(XmlReader reader, string version) { var parsed = false; try { if (version == SyndicationVersions.Rss20 && reader.NamespaceURI == MediaRssBase.NS_URI) { switch (reader.LocalName) { case MediaRssContent.ELEMENT_NAME: var contentNode = new MediaRssContent(); contentNode.ReadXml(reader); ContentNodes.Add(contentNode); parsed = true; break; case MediaRssGroup.ELEMENT_NAME: var groupNode = new MediaRssGroup(); groupNode.ReadXml(reader); GroupNodes.Add(groupNode); parsed = true; break; default: parsed = MediaRssHelper.TryParseOptionalElement(OptionalElements, reader); if (!parsed) parsed = base.TryParseElement(reader, version); break; } } return parsed; } catch (Exception) { //TODO Log error return false; } }