Example #1
0
        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;
        }
Example #2
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));
        }
Example #3
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 );
        }
Example #4
0
        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);
        }