XML_Transformer question

From: Date: Mon, 07 Apr 2003 10:52:52 +0000
Subject: XML_Transformer question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4676@lists.php.net to get a copy of this message
Hi, I have a question about XML_transformer. Would it be possible to specify which namespace is to be parsed when the transform() method is called and have only items from this namespace returned ? I have an xml document that looks like this: <contents> <side:promo> Here goes the promo. </side:promo> <content:content> Here goes the contents. </content:content> </contents> I have two XML_Transformer_Namespace extensions with corresponding start_ and end_ methods: Class XML_Transformer_Side extends XML_Transformer_Namespace start_promo end_promo Class XML_Transformer_Content extends XML_Transformer_Namespace start_content end_content Now create a new XML_Transformer object with these parameters: $parameters['overloadedNamespaces'] = array('content' => new Mamasam_Transformer_Content, 'side' => new Mamasam_Transformer_Side); $parameters['recursiveOperation'] = false; $t = new XML_Transformer($parameters); $content = $t->transform($xml); This code only returns the side part transformed, the content is left as is. I would like to know if there is a way to achieve something like this instead: $content = $t->transform($xml, 'content'); $side = $t->transform($xml, 'side'); And have only the side or the content namespaces parsed. Or maybe there is a better way ? TIA Bertrand Mansion Mamasam

« previous php.pear.general (#4676) next »