Пример #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;
        }
Пример #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));
        }
Пример #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 );
        }
Пример #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);
        }