Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
I'd like to display my results as an xml page. Is there a way I can do this
using Smarty (in use for the rst of my sites)?
My tpl file looks like this:
<?xml version='1.0' encoding='utf-8'?>
<Documents>
<result_size>{$itemcount}</result_size>
{section name=nr loop=$results}
<record id='{$results[nr].tr_id}'>
<AUTHOR>{$results[nr].sa}</AUTHOR>
{$results[nr].sa}
<TITLE>{$results[nr].st}</TITLE>
{$results[nr].ea}
<FRAGMENT_AUTHOR>{$results[nr].ea}</FRAGMENT_AUTHOR>
{$results[nr].vol}
<FRAGMENT_TITLE>{$results[nr].et}</FRAGMENT_TITLE>
{$results[nr].pagerange}
<VOLUME>{$results[nr].vol}</VOLUME>
<ISSUE>{$results[nr].issue}</ISSUE>
<PAGERANGE>{$results[nr].pagerange}</PAGERANGE>
</record>
{/section}
</Documents>
The web result looks like (for one record):
Bryman, Alan Bryman, Alan Chapter 5: The debate about quantitative and
qualitativ 93-126
and the 'view source' is like:
<?xml version='1.0' encoding='utf-8'?>
<Documents>
<result_size>5</result_size>
<record id='50450'>
<AUTHOR>Bryman, Alan</AUTHOR>
<TITLE>Quantity and quality in social research</TITLE>
<FRAGMENT_AUTHOR>Bryman, Alan</FRAGMENT_AUTHOR>
<FRAGMENT_TITLE>Chapter 5: The debate about ...</FRAGMENT_TITLE>
<VOLUME></VOLUME>
<ISSUE></ISSUE>
<PAGERANGE>93-126</PAGERANGE>
</record>
...
</Documents>
Cay anyone point me in the right direction please?
George in Oxford
Post Follow-up to this message* George Pitcher <george.pitcher@ingenta.com>: > I'd like to display my results as an xml page. Is there a way I can do thi s > using Smarty (in use for the rst of my sites)? > > My tpl file looks like this: > <snip - tmpl> > > The web result looks like (for one record): > > Bryman, Alan Bryman, Alan Chapter 5: The debate about quantitative and > qualitativ 93-126 > > and the 'view source' is like: > > <?xml version='1.0' encoding='utf-8'?> > <Documents> > <result_size>5</result_size> > <record id='50450'> > <AUTHOR>Bryman, Alan</AUTHOR> > <TITLE>Quantity and quality in social research</TITLE> > <FRAGMENT_AUTHOR>Bryman, Alan</FRAGMENT_AUTHOR> > <FRAGMENT_TITLE>Chapter 5: The debate about ...</FRAGMENT_TITLE> > <VOLUME></VOLUME> > <ISSUE></ISSUE> > <PAGERANGE>93-126</PAGERANGE> > </record> > ... > </Documents> > > Cay anyone point me in the right direction please? Looks to me like it's working fine, and that the issue is your browser's display of XML. We create XML using Smarty regularly with no issues. Until recently, when we previewed in Firefox we could only see the actual data (no tags); recent builds of Firefox -- with the developer tools enabled -- display a nice XML tree. If ever in doubt, simply look at the source code sent to your browser; if it looks correct, Smarty is doing its work, then. Now, another possibility that I can see here is that you might want to use XSLT to transform the XML into HTML or XHTML (which seems silly -- why not just send HTML back to the browser). If that's the case, you're going to need to do a lot more, and this isn't the place to discuss it. -- Matthew Weier O'Phinney | mailto:matthew@garden.org Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.