4 libxo - A Library for Generating Text, XML, JSON, and HTML Output
6 The libxo library allows an application to generate text, XML, JSON,
7 and HTML output using a common set of function calls. The application
8 decides at run time which output style should be produced. The
9 application calls a function "xo_emit" to product output that is
10 described in a format string. A "field descriptor" tells libxo what
11 the field is and what it means.
13 Imagine a simplified ``wc`` that emits its output fields in a single
17 xo_emit(" {:lines/%7ju/%ju} {:words/%7ju/%ju} "
18 "{:characters/%7ju/%ju}{d:filename/%s}\n",
19 linect, wordct, charct, file);
22 Output can then be generated in various style, using the "--libxo"
28 % wc --libxo xml,pretty,warn /etc/motd
31 <filename>/etc/motd</filename>
34 <characters>1140</characters>
37 % wc --libxo json,pretty,warn /etc/motd
42 "filename": "/etc/motd",
50 % wc --libxo html,pretty,warn /etc/motd
52 <div class="text"> </div>
53 <div class="data" data-tag="lines"> 25</div>
54 <div class="text"> </div>
55 <div class="data" data-tag="words"> 165</div>
56 <div class="text"> </div>
57 <div class="data" data-tag="characters"> 1140</div>
58 <div class="text"> </div>
59 <div class="data" data-tag="filename">/etc/motd</div>
63 View the beautiful documentation at:
65 http://juniper.github.io/libxo/libxo-manual.html
67 [![Analytics](https://ga-beacon.appspot.com/UA-56056421-1/Juniper/libxo/Readme)](https://github.com/Juniper/libxo)