Closed cigzigwon closed 9 years ago
There is no way to do this directly in XMLTransformer. But with version 1.1 (tagged a few minutes ago, which means it will be available via Composer shortly), the callback can take the arguments by reference – as usual, by prefixing the argument with an ampersand. (Exception: this won’t work with PHP 5.3.)
Example callback function:
function callback($elementName, &$attributes, $elementType)
{
$attributes = []; // <-- This will clear all attributes
return [
'@title' => 'You can still set attributes like this',
];
}
Likewise, any other kind of filtering or removal can be accomplished using plain PHP.
sweet man ur awesome! this really works great for me and just started using it.
On Wed, Aug 19, 2015 at 4:46 PM, Carsten Blüm notifications@github.com wrote:
There is no way to do this directly in XMLTransformer. But with version 1.1 (tagged a few minutes ago, which means it will be available via Composer shortly), the callback can take the arguments by reference – as usual, by prefixing the argument with an ampersand. (Exception: this won’t work with PHP 5.3.)
Example callback function:
function callback($elementName, &$attributes, $elementType){ $attributes = []; // <-- This will clear all attributes return [ '@title' => 'You can still set attributes like this', ];}
Likewise, any other kind of filtering or removal can be accomplished using plain PHP.
— Reply to this email directly or view it on GitHub https://github.com/BlueM/XMLTransformer/issues/5#issuecomment-132778742.
I don't see any usage for something like @* OR @name:* which wouldbe very handy for mass removal of unwanted attrs.