/// <summary> /// Constructor /// </summary> /// <param name="Location">Location of the XML file</param> public BlogML(string Location) { Location.ThrowIfNullOrEmpty("Location"); XmlDocument Document = new XmlDocument(); Document.Load(Location); foreach (XmlNode Children in Document.ChildNodes) { if (Children.Name.Equals("blog", StringComparison.CurrentCultureIgnoreCase)) { foreach (XmlNode Child in Children.ChildNodes) { if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Child.InnerText; } else if (Child.Name.Equals("sub-title", StringComparison.CurrentCultureIgnoreCase)) { SubTitle = Child.InnerText; } else if (Child.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Child); } else if (Child.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Child); } else if (Child.Name.Equals("posts", StringComparison.CurrentCultureIgnoreCase)) { Posts = new Posts((XmlElement)Child); } } } } }
/// <summary> /// Constructor /// </summary> /// <param name="Location">Location of the XML file</param> public BlogML(string Location) { Location.ThrowIfNullOrEmpty("Location"); XmlDocument Document = new XmlDocument(); Document.Load(Location); foreach (XmlNode Children in Document.ChildNodes) { if (Children.Name.Equals("blog", StringComparison.CurrentCultureIgnoreCase)) { DateCreated = Children.Attributes["date-created"] != null ? DateTime.Parse(Children.Attributes["date-created"].Value) : DateTime.Now; RootURL = Children.Attributes["root-url"] != null ? Children.Attributes["root-url"].Value : ""; foreach (XmlNode Child in Children.ChildNodes) { if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase)) { Title = Child.InnerText; } else if (Child.Name.Equals("sub-title", StringComparison.CurrentCultureIgnoreCase)) { SubTitle = Child.InnerText; } else if (Child.Name.Equals("authors", StringComparison.CurrentCultureIgnoreCase)) { Authors = new Authors((XmlElement)Child); } else if (Child.Name.Equals("categories", StringComparison.CurrentCultureIgnoreCase)) { Categories = new Categories((XmlElement)Child); } else if (Child.Name.Equals("posts", StringComparison.CurrentCultureIgnoreCase)) { Posts = new Posts((XmlElement)Child); } } } } }
/// <summary> /// Constructor /// </summary> public BlogML() { Authors = new Authors(); Categories = new Categories(); Posts = new Posts(); }