/// <summary> /// Constructor /// </summary> public Post() { Authors = new Authors(); Categories = new Categories(); Tags = new Tags(); Comments = new Comments(); }
/// <summary> /// Constructor /// </summary> /// <param name="Element">Element containing the post info</param> public Post(XmlElement Element) { Element.ThrowIfNull("Element"); DateCreated = DateTime.Now; DateModified = DateTime.Now; ID = Element.Attributes["id"] != null ? Element.Attributes["id"].Value : ""; PostURL = Element.Attributes["post-url"] != null ? Element.Attributes["post-url"].Value : ""; DateCreated = Element.Attributes["date-created"] != null ? DateTime.Parse(Element.Attributes["date-created"].Value) : DateTime.MinValue; DateModified = Element.Attributes["date-modified"] != null ? DateTime.Parse(Element.Attributes["date-modified"].Value) : DateCreated; foreach (XmlNode Children in Element.ChildNodes) { if (Children.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Children.InnerText; } else if (Children.Name.Equals("content", StringComparison.CurrentCultureIgnoreCase)) { Content = Children.InnerText; } else if (Children.Name.Equals("post-name", StringComparison.CurrentCultureIgnoreCase)) { PostName = Children.InnerText; } else if (Children.Name.Equals("excerpt", StringComparison.CurrentCultureIgnoreCase)) { Excerpt = Children.InnerText; } else if (Children.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Children); } else if (Children.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Children); } else if (Children.Name.Equals("tags", StringComparison.CurrentCultureIgnoreCase)) { Tags = new Tags((XmlElement)Children); } else if (Children.Name.Equals("comments", StringComparison.CurrentCultureIgnoreCase)) { Comments = new Comments((XmlElement)Children); } } }