private static int GetMetaIndex( HtmlHead head ) { var lastMeta = head.Element.Elements( "meta" ).LastOrDefault(); if ( lastMeta != null ) return lastMeta.IndexOfSelf() + 1; var titleElement = head.Element.Elements( "title" ).SingleOrDefault(); if ( titleElement != null ) return titleElement.IndexOfSelf() + 1; return 0; }
public static HtmlMeta Create(HtmlHead head, string name, string content) { var factory = head.Element.Document.GetNodeFactory(); var freeElement = factory.CreateElement("meta"); var element = head.Element.Insert(GetMetaIndex(head), freeElement); element.SetAttribute("name", name); element.SetAttribute("content", content); return(new HtmlMeta(element)); }
public static HtmlMeta Create( HtmlHead head, string name, string content ) { var factory = head.Element.Document.GetNodeFactory(); var freeElement = factory.CreateElement( "meta" ); var element = head.Element.Insert( GetMetaIndex( head ), freeElement ); element.SetAttribute( "name", name ); element.SetAttribute( "content", content ); return new HtmlMeta( element ); }
private static int GetMetaIndex(HtmlHead head) { var lastMeta = head.Element.Elements("meta").LastOrDefault(); if (lastMeta != null) { return(lastMeta.IndexOfSelf() + 1); } var titleElement = head.Element.Elements("title").SingleOrDefault(); if (titleElement != null) { return(titleElement.IndexOfSelf() + 1); } return(0); }