Need advice / suggestions

From: Date: Wed, 28 Mar 2001 11:47:31 +0000
Subject: Need advice / suggestions
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-471@lists.php.net to get a copy of this message
Hi Smarty People :) I'd need some suggestive input from you template gods. I am storing data about an object (call it a datasheet) in XML format. This data has to be shown to users in various formats: HTML (summary and complete), but also other text-based layouts (E-mail and fax). I'd like to use Smarty templates to do the rendering. After talking to a colleague, we have come up with the idea to parse the XML using PHP's XML functions, and put all the elements into one or more (that needs to be defined) arrays. The associative arrays would have keys that are the name of the XML element. Also, the Smarty tags would be the names of the XML elements. That way, I could simply assign() the whole XML result array to a smarty template, because the XML tags and the Smarty tags "match". Now the question: I don't really know how to go about to create that array. What especially bogs me is the fact that some elements can have attributes, of course, and some other elements can have a variable amount of sub-elements, like this: <Book> <Author>Alain</Author> <Author>Monte</Author> </Book> I know how to parse XML with PHP, either the Expat way, or the DOM way, so that's not really part of the question. It's mainly about how to effectively use XML/PHP/Smarty to transform an XML document into a nice HTML. I know I could have used XSLT, but I prefer the Smarty way. That's today's exercise... :). I'd be happy about any suggestion / idea you could have ! Thanks !

« previous php.smarty.general (#471) next »