| 
	
 | 
 Posted by boots on 06/04/05 02:50 
--- 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
 
  
Navigation:
[Reply to this message] 
 |