xml
| Rivet Tcl Commands and Variables |

## Name

xml — XML Fragments creation

## Synopsis

::rivet::xml ?string? ?tag descriptor? ?tag descriptor? ?...?

## Description

Given a string and a variable number of tag descriptors return XML fragment made by nesting the tags with the same hierarchical order they are listed on the command line. The tag descriptors can be a one element list (the tag) or an odd-length list whose first argument is the tag namme and the remaining elements are interpreted as attribute name-attribute value pairs.

::rivet::xml can work as a replacement of ::rivet::html provided you take care of sending the string with command puts

    ::rivet::xml "a string" b u
    <== <b><u>a string</u></b>

You can specify the tags attributes by replacing a tag specification with a odd-length list containing the tag name and a series of attribute-value pairs

    ::rivet::xml "a string" [list div class box id testbox] b i
    <== <div class="box" id="testbox"><b><i>a string</i></b></div>

    ::rivet::xml "text to be wrapped in XML" div [list a href http://..../ title "info message"]
    <== <div><a href="http://..../" title="info message">text to be wrapped in XML</a></div>

A single argument is interpreted as a list of tag name and attributes to be coded as a self closing element

    ::rivet::xml [list b a1 v1 a2 v2]
    <== <b a1="v1" a2="v2" />

Unless the string is literally an empty string

    ::rivet::xml "" [list b a1 v1 a2 v2]
    <== <b a1="v1" a2="v2"></b>

which is useful for generating 'script' elements in an HTML page header that wouldn't be understood as single closing element

    ::rivet::xml "" [list script type "text/javascript" src js/myscripts.js]
    <== <script type="text/javascript" src="js/myscripts.js"></script>

wrapline |  | Examples and Usage