コード例 #1
0
        public override IHtmlElement Create(HtmlAttributesCollection attributes, string html, IHtmlParserManager htmlParserManager)
        {
            HtmlDocTypeElement document = new HtmlDocTypeElement();

            document.Attributes = attributes;
            return(document);
        }
コード例 #2
0
        private unsafe void LoadRaw()
        {
            Debug.Assert(m_XmlDoc != null);

            if (string.IsNullOrEmpty(m_RawHtml))
            {
                return;
            }

            lock (m_SyncLock)
            {
                m_DocTypeElement   = null;
                m_BodyElement      = null;
                m_HeadElement      = null;
                m_HtmlElement      = null;
                m_NamespaceManager = null;

                char[] rawData = m_Encoding.GetChars(m_Encoding.GetBytes(m_RawHtml));

                fixed(char *charData = rawData)
                {
                    if (m_Parser != null)
                    {
                        // If this is not the first parse operation then create a new doc
                        m_XmlDoc = new XmlDocument();
                        base.InitXmlNode(m_XmlDoc, this);
                    }

                    m_Parser = new HtmlParser(m_FixupMode);

                    m_Parser.Parse(rawData, charData, this);
                }
            }
        }
コード例 #3
0
        private void ChildAppending(HtmlNode child, ref OnChildAppendingEventArgs e)
        {
            // NOTE: All "<!DOCTYPE" elements are *always* added to the HtmlDocument by the parser
            //       so we cannot miss a "<!DOCTYPE" on a wrong place
            if (child is HtmlDocTypeElement)
            {
                // Dont add the DocType element. This will stuff up the XPath queries
                e.Cancel = true;

                if (m_DocTypeElement == null)
                {
                    m_DocTypeElement = child as HtmlDocTypeElement;

                    //<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
                    //<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    //<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
                    //<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
                    //<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
                    //<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">
                    //<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

                    // By default use Html 4.01 Strict
                    m_HtmlDtd = HtmlDtd.Html401;

                    if (!string.IsNullOrEmpty(m_DocTypeElement.PublicId))
                    {
                        string[] tokens = m_DocTypeElement.PublicId.Split(new string[] { "//" }, StringSplitOptions.None);

                        if (tokens.Length > 2)
                        {
                            if (tokens[1] == "W3C")
                            {
                                string dtd = tokens[2].Substring(4);

                                if (dtd == XHTML_ST)
                                {
                                    m_HtmlDtd = HtmlDtd.XhtmlStrict;
                                }

                                if (dtd == XHTML_TR)
                                {
                                    m_HtmlDtd = HtmlDtd.XhtmlTransitional;
                                }

                                if (dtd == XHTML_FR)
                                {
                                    m_HtmlDtd = HtmlDtd.XhtmlFrameset;
                                }

                                if (dtd == HTML_4_01)
                                {
                                    m_HtmlDtd = HtmlDtd.Html401;
                                }

                                if (dtd == HTML_4_01_TR)
                                {
                                    m_HtmlDtd = HtmlDtd.Html401Transitional;
                                }

                                if (dtd == HTML_4_01_FR)
                                {
                                    m_HtmlDtd = HtmlDtd.Html401Frameset;
                                }

                                if (dtd == HTML_3_2)
                                {
                                    m_HtmlDtd = HtmlDtd.Html32;
                                }
                            }
                        }
                    }
                }
            }
        }