[webkit-gtk] webkit_dom_element_get_elements_by_tag_name doesn't work properly
Ángel Luis Perales Gómez
angelluispg89 at hotmail.com
Fri Dec 13 02:33:28 PST 2013
Sorry, I was very busy and I couldn't see the mail list.
Finally I fixed the error, it was my fault. As you say I should use webkit_dom_document_get_elements_by_tag_name() insted of webkit_dom_element_get_elements_by_tag_name(). But I had other problem, I didn't wait until webpage load finish.
I explain my problem at StackOverflow and there explain the solution. It can useful for other people so I put the link:
http://stackoverflow.com/questions/20123619/webkit-dom-element-get-elements-by-tag-name-doesnt-work-properly
Thanks everyone.
> Subject: Re: [webkit-gtk] webkit_dom_element_get_elements_by_tag_name doesn't work properly
> From: cgarcia at igalia.com
> To: angelluispg89 at hotmail.com
> CC: webkit-gtk at lists.webkit.org
> Date: Fri, 13 Dec 2013 11:03:46 +0100
>
> El jue, 21-11-2013 a las 20:25 +0100, Ángel Luis escribió:
> > I am trying to print name of nodes from DOM with WebKitGTK with the
> > following code:
>
> Sorry for the late reply, I haven't had time to look at this problem
> until now.
>
> > WebKitDOMDocument *dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webView));
> > WebKitDOMNodeList* video = webkit_dom_element_get_elements_by_tag_name(dom, "*");
>
> This line is wrong, WebKitDOMDocument is not a WebKitDOMElement, you
> should use webkit_dom_document_get_elements_by_tag_name() instead. What
> WebKitGTK+ version are you using? because recent versions will give a
> runtime error when passing the wrong DOM object to a method.
>
> >
> > gulong element_count = webkit_dom_node_list_get_length(video);
> > int i = 0;
> > for (i = 0; i < element_count; i++)
> > {
> > WebKitDOMNode *element = webkit_dom_node_list_item(video, i);
> > printf("tag: %s\n",webkit_dom_node_get_node_name (element));
> >
> > }
> >
> >
> > And I have the following webpage:
> >
> > <!DOCTYPE html>
> > <html>
> > <head>
> > </head>
> > <body>
> > <video id="video" autoplay preload="none" width="320"
> > height="240">
> > <source src="./movie.ogg" type="video/ogg">
> > Your browser does not support the video tag.
> > </video>
> > <video id="video2" width="320" height="240" autoplay
> > preload="none">
> > <source src="./movie.ogg" type="video/ogg">
> > Your browser does not support the video tag.
> > </video>
> > <input type="hidden" id="prueba" name="finish" value="false">
> > </body>
> > </html>
>
> I have a added this as a test case to WebKit2 DOM bindings tests, see
> bug:
>
> https://bugs.webkit.org/show_bug.cgi?id=125686
>
> >
> >
> > And the output of my program is:
> >
> > tag: HTML
> > tag: HEAD
> > tag: BODY
> >
> > I don't understand why it output that, the output should be:
> >
> > tag: HTML
> > tag: HEAD
> > tag: BODY
> > tag: VIDEO
> > tag: SOURCE
> > tag: VIDEO
> > tag: SOURCE
> > tag: INPUT
>
> I'm getting this.
>
> > Anyone know what's happend?
>
> No idea, maybe it was because you were using the wrong method.
>
> > Thanks
> >
> >
> > _______________________________________________
> > webkit-gtk mailing list
> > webkit-gtk at lists.webkit.org
> > https://lists.webkit.org/mailman/listinfo/webkit-gtk
>
> --
> Carlos Garcia Campos
> http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xF3D322D0EC4582C3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-gtk/attachments/20131213/446b21de/attachment.html>
More information about the webkit-gtk
mailing list