Re: [SMARTY] smarty + XML

From: Date: Fri, 03 Jun 2005 23:50:54 +0000
Subject: Re: [SMARTY] smarty + XML
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12667@lists.php.net to get a copy of this message
--- messju mohr <messju@lammfellpuschen.de> wrote: > honestly: i think simple-xml looks pretty slick at first sight, but > totally brain-damaged (if not -dead) at second sight. but that > personal impression may just be by me, because i'm not bright enough > to get it properly. I think the jury is still out but I tend to agree with your premise -- I don't know of any in-production uses of these techniques either (at least with Smarty involved). Then again, I still don't have any PHP5 production sites (though the first is coming in a few weeks). > ... > > if you want to access child-elements of a node use {$node->child}, > if you want to access attributes of a node use {$node.attrname}, > if you want to dump the contents of a node use {$node} It is definately a "magic" object that takes getting used to. Still, it seems like it is rather concise and compact once its usage pattern starts to really sink-in. I hope that happens for me soon. I just thought I'd mention another interesting use of SimpleXML within Smarty: access to xpath queries. eg: {* use xpath to select 'rating' nodes and show attribute access *} {foreach from=$simplexml->xpath('/movies/movie/rating') item=node key=key} $key: {$key}, $node: {$node}, $node.type: {$node.type}<br /> {/foreach} http://www.phpinsider.com/smarty-forum/viewtopic.php?p=19729#19729 If you are committed to XML data then SimpleXML can be quite useful because the old domxml extension was even more frustrating and the SAX engine, while good, required a lot of tedious and error-prone userland code to do anything useful. If you aren't committed to XML data then SimpleXML is just a side-show. xo boots > greetings > messju

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