GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
XO(1) FreeBSD General Commands Manual XO(1)

xo
emit formatted output based on format string and arguments

xo [-options] [argument...]

The xo utility allows command line access to the functionality of the libxo library. Using xo, shell scripts can emit XML, JSON, or HTML using the same commands that emit text output.
Close tags for the given path
Set the depth for pretty printing
Display this help text
Generate HTML output
Generate JSON output
Add a prefix to generated XPaths (HTML)
Open tags for the given path
Make 'pretty' output (add indent, newlines)
Generate given style (xml, json, text, html)
Generate text output (the default style)
Display version information
Display warnings in text on stderr
Display warnings in xml on stdout
Wrap output in a set of containers
Generate XML output
Add XPath data to HTML output

The xo utility accepts a format string suitable for xo_emit(3) and a set of zero or more arguments used to supply data for that string.

    xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6

  TEXT:
    The fish weighs 6 pounds.
  XML:
    <name>fish</name>
    <weight>6</weight>
  JSON:
    "name": "fish",
    "weight": 6
  HTML:
    <div class="line">
      <div class="text">The </div>
      <div class="data" data-tag="name">fish</div>
      <div class="text"> weighs </div>
      <div class="data" data-tag="weight">6</div>
      <div class="text"> pounds.</div>
    </div>

The --wrap <path> option can be used to wrap emitted content in a specific hierarchy. The path is a set of hierarchical names separated by the '/' character.

    xo --wrap top/a/b/c '{:tag}' value

  XML:
    <top>
      <a>
        <b>
          <c>
            <tag>value</tag>
          </c>
        </b>
      </a>
    </top>
  JSON:
    "top": {
      "a": {
        "b": {
          "c": {
            "tag": "value"
          }
        }
      }
    }

The --open <path> and --close <path> can be used to emit hierarchical information without the matching close and open tag. This allows a shell script to emit open tags, data, and then close tags. The --depth option may be used to set the depth for indentation. The --leading-xpath may be used to prepend data to the XPath values used for HTML output style.

    #!/bin/sh
    xo --open top/data
    xo --depth 2 '{tag}' value
    xo --close top/data
  XML:
    <top>
      <data>
        <tag>value</tag>
      </data>
    </top>
  JSON:
    "top": {
      "data": {
        "tag": "value"
      }
    }

  % xo 'The {:product} is {:status}0 stereo "in route"
  The stereo is in route
  % xo -p -X 'The {:product} is {:status}0 stereo "in route"
  <product>stereo</product>
  <status>in route</status>

libxo(3), xo_emit(3)

FreeBSD uses libxo version 0.6.1. Complete documentation can be found on github:
http://juniper.github.io/libxo/0.6.1/libxo-manual.html

libxo lives on github as:

https://github.com/Juniper/libxo

The latest release of libxo is available at:

https://github.com/Juniper/libxo/releases

The libxo library was added in FreeBSD 11.0.

Phil Shafer
December 4, 2014 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.