/// <summary> /// /// </summary> /// <param name="entryEl"></param> /// <param name="nsMgr"></param> /// <param name="rel"></param> /// <param name="contentType">e.g. application/atom+xml</param> /// <param name="contentSubType">e.g. "entry"</param> /// <param name="baseUri"></param> /// <returns></returns> public static string GetLink(IXmlNode entryEl, XmlNamespaceManager nsMgr, string rel, string contentType, string contentSubType, Uri baseUri) { Debug.Assert(contentSubType == null || contentType != null, "contentSubType is only used if contentType is also provided"); string xpath = string.Format(CultureInfo.InvariantCulture, @"atom:link[@rel='{0}']", rel); foreach (XmlElement link in entryEl.SelectNodesNS(xpath, nsMgr.ToNSMethodFormat())) { if (contentType != null) { string mimeType = link.GetAttribute("type"); if (mimeType == null || mimeType == "") { continue; } IDictionary mimeData = MimeHelper.ParseContentType(mimeType, true); if (contentType != (string)mimeData[""]) { continue; } if (contentSubType != null && contentSubType != (string)mimeData["type"]) { continue; } } return(XmlHelper.GetUrl(link, "@href", baseUri)); } return(""); }
public override void RemoveAllCategories(IXmlNode node, string categoryScheme, Uri documentUri) { if (categoryScheme == null) { return; } XmlNamespaceManager nsMgr = new XmlNamespaceManager(new NameTable()); nsMgr.AddNamespace("atom", NamespaceUri); ArrayList nodesToRemove = new ArrayList(); foreach (XmlElement categoryEl in node.SelectNodesNS("atom:category", nsMgr.ToNSMethodFormat())) { string scheme = categoryEl.GetAttribute("scheme"); if (SchemesEqual(scheme, categoryScheme)) { nodesToRemove.Add(categoryEl); } } foreach (XmlElement categoryEl in nodesToRemove) { categoryEl.ParentNode.RemoveChild(categoryEl); } }