public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { if (tag.Attributes.ContainsKey(key) == false) tag.Attributes.Add(key, val); else if (tag.Attributes.ContainsKey(ns + ":" + key) == false) tag.Attributes.Add(ns + ":" + key, val); }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { if (subOutput != null) subOutput.ParsedAttribute(tag, ns, key, val); }
public Tag Element(TagNamespace ns, string tagName) { tagName = tagName.ToLowerInvariant(); foreach(var t in Children) { if (!ns.Equals(t.Namespace)) continue; if (t.Name == tagName) return t; } return null; }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { key = key.ToLowerInvariant(); if (tag.Attributes.ContainsKey(key)) return; val = HttpUtility.HtmlDecode(val); switch (key) { case "href": if (!Uri.IsWellFormedUriString(val, UriKind.Absolute)) return; tag.Attributes.Add("href", new Uri(val).ToString()); return; case "src": if (tag.Name != "img") return; if (!Uri.IsWellFormedUriString(val, UriKind.Absolute)) return; tag.Attributes.Add("src", new Uri(val).ToString()); return; case "alt": case "align": case "border": case "cite": case "coords": case "datetime": case "download": case "for": case "headers": case "height": case "high": case "hreflang": case "low": case "media": case "min": case "max": case "open": case "optimum": case "pubdate": case "rel": case "reversed": case "shape": case "span": case "start": case "summary": case "title": case "type": case "value": case "width": case "wrap": tag.Attributes.Add(key, val); return; case "target": switch (val) { case "_self": case "_blank": //case "_parent": case "_top": tag.Attributes.Add(key, val); return; } return; case "cols": case "colspan": case "rows": case "rowspan": //Integer values int iv; if (int.TryParse(val, out iv)) tag.Attributes.Add(key, iv.ToString()); return; } }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { if (string.IsNullOrWhiteSpace(val)) return; output.ParsedAttribute(tag, ns, key, val); }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { key = key.ToLowerInvariant(); val = HttpUtility.HtmlDecode(val); tag.Attributes.Add(key, val); }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { tag.Attributes.Add(key, val); }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { if(tag.Attributes.ContainsKey(key)) throw new ArgumentException("duplicate key: " + key + " = " + val); tag.Attributes.Add(key, val); }
public void ParsedAttribute(Tag tag, TagNamespace ns, string key, string val) { output.ParsedAttribute(tag, ns, key, val); }