Browse thread
[Caml-list] Looking for OCaml code to load & save XML files
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-02-29 (18:13) |
From: | Nicolas Cannasse <warplayer@f...> |
Subject: | Re: [Caml-list] Looking for OCaml code to load & save XML files |
> > My advice : first experiment XmlLight and then switch to PXP if you lack > > features. > > > > http://tech.motion-twin.com/xmllight > > I like you advice. I've looked at your library and it's conciseness and > lack of dependencies pleases me. > > BTW, I need to save some short binary data in the XML format (e.g. MD5 > 128bits hash). Therefore, I would like to transform from/to an OCaml > binary string type into a string suitable for printing in an XML file > (in a CDATA field). Which code would you recommend to do that the "XML > way"? At first sight, I intend to use Gerd's code to encode/decode MIME > and base64 strings. If your goal is to minimise dependencies, just writing some lines of B64 encode/decode is a good idea (btw, this could be a good add-on for ExtLib : http://ocaml-lib.sf.net ). > As another side note, I also intend to read and write gziped XML files, > using Xavier's camlzip package. As your module uses Lexing.from_* to get > input file, I'll probably add an SFunction source type to be able to use > Lexing.from_function. In the same way, I'll probably modify your output > functions (Xml.to_string) to be able to ouput into a Gzip.out_channel > without producing the whole XML file in a string. > > I'll gladly accept any advice on how to use your code, I think you don't need any special advice in order to add the SFunction to XmlLight, it looks easy. For gzip, XmlLight has 2 printers : Xml.to_string for "compact" mode (without any line returns or indentation) and Xml.to_string_fmt for "formatted" mode (a lot more user-readable). Writing a custom "compact" printer which directly output the data into a Gzip.out_channel is also something easy to do (look at to_string in xml.ml for example). Another way is to add an event-driven printer that would be able to output on any underlying data structure. If you need this, don't hesitate to ask and I will add this to XmlLight. You can contact me again if you have any question. Regards, Nicolas Cannasse ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners