public static void WriteOpmlItem(OpmlItem item, XmlWriter writer) { item.RenderOpml(writer); foreach (OpmlItem childItem in item.ChildItems) { WriteOpmlItem(childItem, writer); } }
public static IEnumerable <OpmlItem> DeserializeItem(XPathNavigator nav) { var items = new List <OpmlItem>(); if (nav.HasAttributes) { string title = nav.GetAttribute("title", ""); if (String.IsNullOrEmpty(title)) { title = nav.GetAttribute("text", ""); } string htmlUrl = nav.GetAttribute("htmlurl", ""); if (String.IsNullOrEmpty(htmlUrl)) { htmlUrl = nav.GetAttribute("htmlUrl", ""); } string xmlUrl = nav.GetAttribute("xmlurl", ""); if (String.IsNullOrEmpty(xmlUrl)) { xmlUrl = nav.GetAttribute("xmlUrl", ""); } OpmlItem currentItem = null; string description = nav.GetAttribute("description", ""); if (!String.IsNullOrEmpty(title) && !String.IsNullOrEmpty(htmlUrl)) { currentItem = new OpmlItem(title, description, xmlUrl, htmlUrl); } if (null != currentItem) { items.Add(currentItem); } } if (nav.HasChildren) { XPathNodeIterator childItems = nav.SelectChildren("outline", ""); while (childItems.MoveNext()) { IEnumerable <OpmlItem> children = DeserializeItem(childItems.Current); if (null != children) { items.InsertRange(items.Count, children); } } } return(items); }
private void ImportOpmlItem(OpmlItem item) { foreach (OpmlItem childItem in item.ChildItems) ImportOpmlItem(childItem); Link newLink = new Link(); newLink.Title = item.Title; newLink.Url = item.HtmlUrl; newLink.Rss = item.XmlUrl; newLink.CategoryID = _categoryID; // TODO: let user specify and pass as command props newLink.IsActive = true; newLink.NewWindow = false; // this isn't a valid collision test really if (!_allLinks.Contains(newLink)) Links.CreateLink(newLink); }
public static IEnumerable<OpmlItem> DeserializeItem(XPathNavigator nav) { var items = new List<OpmlItem>(); if (nav.HasAttributes) { string title = nav.GetAttribute("title", ""); if (String.IsNullOrEmpty(title)) { title = nav.GetAttribute("text", ""); } string htmlUrl = nav.GetAttribute("htmlurl", ""); if (String.IsNullOrEmpty(htmlUrl)) { htmlUrl = nav.GetAttribute("htmlUrl", ""); } string xmlUrl = nav.GetAttribute("xmlurl", ""); if (String.IsNullOrEmpty(xmlUrl)) { xmlUrl = nav.GetAttribute("xmlUrl", ""); } OpmlItem currentItem = null; string description = nav.GetAttribute("description", ""); if (!String.IsNullOrEmpty(title) && !String.IsNullOrEmpty(htmlUrl)) { currentItem = new OpmlItem(title, description, xmlUrl, htmlUrl); } if (null != currentItem) { items.Add(currentItem); } } if (nav.HasChildren) { XPathNodeIterator childItems = nav.SelectChildren("outline", ""); while (childItems.MoveNext()) { IEnumerable<OpmlItem> children = DeserializeItem(childItems.Current); if (null != children) { items.InsertRange(items.Count, children); } } } return items; }
public static OpmlItem[] DeserializeItem(XPathNavigator nav) { ArrayList items = new ArrayList(); if (nav.HasAttributes) { string title = nav.GetAttribute("title", ""); if (String.IsNullOrEmpty(title)) title = nav.GetAttribute("text", ""); string htmlUrl = nav.GetAttribute("htmlurl", ""); if (String.IsNullOrEmpty(htmlUrl)) htmlUrl = nav.GetAttribute("htmlUrl", ""); string xmlUrl = nav.GetAttribute("xmlurl", ""); if (String.IsNullOrEmpty(xmlUrl)) xmlUrl = nav.GetAttribute("xmlUrl", ""); OpmlItem currentItem = null; string description = nav.GetAttribute("description", ""); if (!String.IsNullOrEmpty(title) && !String.IsNullOrEmpty(htmlUrl)) currentItem = new OpmlItem(title, description, xmlUrl, htmlUrl); if (null != currentItem) items.Add(currentItem); } if (nav.HasChildren) { XPathNodeIterator childItems = nav.SelectChildren("outline", ""); while (childItems.MoveNext()) { OpmlItem[] children = DeserializeItem(childItems.Current); if (null != children) items.InsertRange(items.Count, children); } } OpmlItem[] result = new OpmlItem[items.Count]; items.CopyTo(result); return result; }