Skip to content

FormatAll

Applies the specified template to every node selected by the XPath and joins the results with a separator.

1
myXml.FormatAll(xpath: string, separator: string, template: string, options?: object):string

Parameters

string xpath
    The XPath of the nodes to format.

string separator
    The string placed between the formatted results.

string template
    Template to apply to each node. XPath expressions in the template are relative to that node.

object options optional
    Optional template options, as in Xml.Format.

Returns

The joined results. Returns an empty string when no node matches.

Remarks

Available only in server scripts.

Examples

Build a line summary

1
2
var summary = $Xml.FormatAll('Lines/Line', ', ', '{{Product}} x {{Quantity}}');
// 'Pen x 2, Notebook x 1'

Build HTML table rows for a message body

1
2
var rows = $Xml.FormatAll('Lines/Line', '', '<tr><td>{{Product}}</td><td>{{Quantity}}</td></tr>');
var html = '<table>' + rows + '</table>';

See Also