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:

[FormFields]
wb_basename=biblio.mdb
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_Command=Q
WB_MaxRec=$all$
WB_Order=[Year published] desc
WB_ContentType=text/xml
<!--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-->
<Titles>
<Title>$wbmrepl[$wbf[Title]|',&|&apos;,&amp;]</Title>
<Year_x0020_Published>$wbf[year published]</Year_x0020_Published>
<ISBN>$wbf[isbn]</ISBN>
<Author>$wbf[Author]</Author>
<Publisher>$wbf[Publisher]</Publisher>
</Titles><!--WB_EndDetail-->
</dataroot>

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.