Drup provided the easiest answer, that is using Tyxml_js. In particular it provides a functional (reactive) API to update the DOM, which is a lot better than using the [createElement] functions. Also, using [Dom_svg.document] here is not appropriate since you want the SVG fragment to be embedded in HTML. This function should be used when the whole document is an SVG. 2016-01-02 21:42 GMT+01:00 : > Indeed TyXML can generate XHTML trees with svg elements. > But how to use that to update the DOM from JS generated by js_of_ocaml? > > # echo > toto.ml < let svg = Dom_svg.createSvg Dom_html.window##document > EOF > # ocamlfind ocamlc -syntax camlp4o -package "js_of_ocaml > js_of_ocaml.syntax" -c toto.ml > Error: This expression has type Dom_html.document Js.t > but an expression was expected of type Dom_svg.document Js.t > Type > Dom_html.document = (... yanked for sanity ...) > is not compatible with type > Dom_svg.document = (... yum yum ...) > The second object type has no method anchors > > Apparently that's a known issue of js_of_ocaml: > https://github.com/ocsigen/js_of_ocaml/issues/276 > > that I don't know how to work around nicely, may be because I have no idea > how > js_of_ocaml interacts with tyxml. I guess you are the pveber of that > discussion > so probably you can shed some light on this? >