Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/XML-Output/OCaml/xml-output-1.ocaml
Normal file
23
Task/XML-Output/OCaml/xml-output-1.ocaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# #directory "+xml-light" (* or maybe "+site-lib/xml-light" *) ;;
|
||||
|
||||
# #load "xml-light.cma" ;;
|
||||
|
||||
# let data = [
|
||||
("April", "Bubbly: I'm > Tam and <= Emily");
|
||||
("Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\"");
|
||||
("Emily", "Short & shrift");
|
||||
] in
|
||||
let tags =
|
||||
List.map (fun (name, comment) ->
|
||||
Xml.Element ("Character", [("name", name)], [(Xml.PCData comment)])
|
||||
) data
|
||||
in
|
||||
print_endline (
|
||||
Xml.to_string_fmt (Xml.Element ("CharacterRemarks", [], tags)))
|
||||
;;
|
||||
<CharacterRemarks>
|
||||
<Character name="April">Bubbly: I'm > Tam and <= Emily</Character>
|
||||
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
|
||||
<Character name="Emily">Short & shrift</Character>
|
||||
</CharacterRemarks>
|
||||
- : unit = ()
|
||||
22
Task/XML-Output/OCaml/xml-output-2.ocaml
Normal file
22
Task/XML-Output/OCaml/xml-output-2.ocaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#directory "+xmlm"
|
||||
#load "xmlm.cmo"
|
||||
open Xmlm
|
||||
|
||||
let datas = [
|
||||
("April", "Bubbly: I'm > Tam and <= Emily");
|
||||
("Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\"");
|
||||
("Emily", "Short & shrift");
|
||||
]
|
||||
|
||||
let xo = make_output (`Channel stdout)
|
||||
|
||||
let () =
|
||||
output xo (`Dtd None);
|
||||
output xo (`El_start (("", "CharacterRemarks"), []));
|
||||
List.iter (fun (name, content) ->
|
||||
output xo (`El_start (("", "Character"), [(("", "name"), name)]));
|
||||
output xo (`Data content);
|
||||
output xo (`El_end);
|
||||
) datas;
|
||||
output xo (`El_end);
|
||||
print_newline()
|
||||
Loading…
Add table
Add a link
Reference in a new issue