Magic Pipes
Documentation
Login

mpxml-write

Reads sexprs from standard input and converts them to JSON documents using the sxml-serializer egg, which are written to standard output. The input sexprs must be valid SXML.

Example

$ cat test.csv
Name,Age
Alaric,38
Jean,11
Mary,6
$ mpcsv-read < test.csv | mptable2alist -H
((Name . "Alaric") (Age . "38"))
((Name . "Jean") (Age . "11"))
((Name . "Mary") (Age . "6"))
$ mpcsv-read < test.csv | mptable2alist -H | mpmap "(lambda (alist) (cons 'Person (map (lambda (elem) (list (car elem) (cdr elem))) alist)))"
(Person (Name "Alaric") (Age "38"))
(Person (Name "Jean") (Age "11"))
(Person (Name "Mary") (Age "6"))
$ mpcsv-read < test.csv | mptable2alist -H | mpmap "(lambda (alist) (cons 'Person (map (lambda (elem) (list (car elem) (cdr elem))) alist)))" | mpxml-write
<Person>
  <Name>Alaric</Name>
  <Age>38</Age>
</Person>
<Person>
  <Name>Jean</Name>
  <Age>11</Age>
</Person>
<Person>
  <Name>Mary</Name>
  <Age>6</Age>
</Person>