示例#1
0
 internal Document(GumboDocumentNode node, GumboFactory factory)
     : base(node, null)
 {
     _children         = factory.CreateLazy(() => ImmutableArray.CreateRange(node.GetChildren().OrderBy(x => x.index_within_parent).Select(x => factory.CreateNode(x, this))));
     HasDocType        = node.document.has_doctype;
     Name              = NativeUtf8.StringFromNativeUtf8(node.document.name);
     PublicIdentifier  = NativeUtf8.StringFromNativeUtf8(node.document.public_identifier);
     SystemIdentifier  = NativeUtf8.StringFromNativeUtf8(node.document.system_identifier);
     DocTypeQuirksMode = node.document.doc_type_quirks_mode;
 }
示例#2
0
文件: Gumbo.cs 项目: h3ml/gumbo.net
        public Gumbo(string html, GumboLibraryOptions?options = null)
        {
            _options   = CreateOptions(options);
            _html      = NativeUtf8.NativeUtf8FromString(html);
            _outputPtr = NativeMethods.gumbo_parse(_html);
            var output = Marshal.PtrToStructure <GumboOutput>(_outputPtr);

            _gumboDocumentNode = output.GetDocument();
            Errors             = output.GetErrors();
            var lazyFactory = new LazyFactory(() => _disposed, typeof(Gumbo).Name);

            _gumboFactory = new GumboFactory(lazyFactory);
            Document      = (Document)_gumboFactory.CreateNode(_gumboDocumentNode);
        }
示例#3
0
 public static XDocument ToXDocument(this GumboDocumentNode docNode) => (XDocument)CreateXNode(docNode);
示例#4
0
 public static IEnumerable <GumboNode> GetChildren(this GumboDocumentNode node) => MarshalToPtrArray(node.document.children).Select(MarshalToSpecificNode);