Am Dienstag, den 17.03.2009, 12:01 +0100 schrieb Rémi Dewitte:
> Hello,
> 
> I have used pxp to parse xml and I am happy with it. I'd like now to
> produce xml and wonder what are the options to do so (possibly the
> simpliest).

Maybe not the simplest: Use the PXP preprocessor to create the output
tree, and print the tree:

http://projects.camlcity.org/projects/dl/pxp-1.2.1/doc/manual/html/ref/Intro_preprocessor.html
http://projects.camlcity.org/projects/dl/pxp-1.2.1/doc/manual/html/ref/Pxp_document.document.html#2_WritingdocumentsasXMLtext


> 
> I think I am going to start with the Printf module. I wonder how well
> it handles utf8 for example. 

UTF-8 are just bytes for printf.

> And I'll have to write a kind of xml_encode function. I am pretty sure
> it has already be done somewhere !

let xml_encode =
  Netencoding.Html.encode 
    ~in_enc:`Enc_utf8
    ~out_enc:`Enc_usascii
    ~prefer_names:false
    ()

That would assume the input is UTF-8 encoded, and the output is
ASCII-encoded. You can control which ASCII characters get the special
XML representation &...; with the unsafe_chars optional argument.
Docs are at
http://projects.camlcity.org/projects/dl/ocamlnet-2.2.9/doc/html-main/Netencoding.Html.html

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
g...@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to