Displaying records in XML format

In other examples we used $WBDetail function, but in some cases there is a need for placing the database field in a specific location on your report, or even not using HTML at all. In that case we do not use $WBDetail function but some (or all) of database field functions $WBF, $WBFF, $WBFC, $WBFU and $WBRF. We also use <!--WB_BeginDetail--> and <!--WB_EndDetail--> comments to define the detail section (section that will be repeated for every record). In this example we will modify the code so it will return recordset in XML format:

WB_RcdSet=(Authors inner join titles on authors.au_id=titles.au_id) inner join publishers on publishers.pubid=titles.pubid
WB_DBFlds=Title,[Year Published],ISBN,Authors.Name as Author,publishers.Name as Publisher
WB_Order=[Year published] desc
<!--WB_BeginTemplate--><?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2008-10-02T12:24:19"><!--WB_BeginDetail-->
<Year_x0020_Published>$wbf[year published]</Year_x0020_Published>

We modified WB_MaxRec to special value $all$ (this will show all records from recordset in a single report page) and set the WB_ContentType variable to text/xml. Note that we also had to use $WBMREPL function to replace apostrophe and ampersand characters in field "Title" due to syntax rules of XML.