[webkit-dev] Working XPath example via GDOM-Binding

Leon Winter lwi at ring0.de
Tue Jun 9 10:17:56 PDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
>> Just grabbed the latest git.
>>  make complains about that:
>>
>>  ar: DerivedSources/.libs/JSCSSCharsetRule.o: No such file or directory
>
>  yeah, i got that too - bizarre that you repeated it. it's because the
> .lo file exists but the .o does not.
>
>  so if you delete the .lo then the build process happily recreates the .o
>
>  do rm DerivedSources/.libs/JS*.lo and then make.
>
>  if that _really_ doesn't work then do make clean - failing that, make
> distclean.
>
>  btw you really should install ccache it will save a ton of time.
>
>  l.
Actually it was "rm DerivedSources/JS*.lo". Thanks for all your help
so far.

Here is a working XPath sample:

    GdomXPathResult *res;
    char* exp = "//*[@href or @src]";
    GdomDocument *doc = get_dom_document();
    GdomNodeList *els = gdom_document_get_elements_by_tag_name(doc,
"body");
    GdomNode *body = gdom_node_list_item(els, 0);
    GdomXPathNSResolver *resolver =
gdom_document_create_ns_resolver(doc, body);
    GdomNode *node;
    GdomCSSStyleDeclaration *style;
    int i = 0;

    res = gdom_document_evaluate(doc, exp, body, resolver, 0, NULL);
    while(res && (node = gdom_x_path_result_iterate_next(res))) {
        g_object_get(node, "style", &style, NULL);
        gdom_css_style_declaration_set_css_property(style, "border",
"1px dashed red", "");
        gdom_css_style_declaration_set_css_property(style,
"background", "yellow", "");
        g_object_unref(style);
        g_object_unref(node);
        ++i;
    }
    g_object_unref(resolver);
    g_object_unref(body);
    g_object_unref(els);
    g_object_unref(doc);
    g_object_unref(res);

    g_warning("found elements: %d\n", i);

Next thing interesting thing would be knowing how to set fifth arg for
gdom_document_evaluate which is an enum that controls the output
order. As far as I know the enum is not exported via binding so at the
moment we have to set this value by hand.

Regards,
Leon Winter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoumUQACgkQ3qn9m9SfDYf2CgCgxTL6Xw952lf5VfkCoo/rnxYw
hnMAn16Y6TXkkx6XMiywhtQQ3RdW08vI
=NTsv
-----END PGP SIGNATURE-----



More information about the webkit-dev mailing list