/* *** *** Simple Macro XML -> JSON via PHP *** By Brendon Irwin *** Note: works for simple conversion but I have not tested extensively **/ #set ( $data = $_XPathTool.selectNodes($contentRoot, "//system-page") ) #macro ( toArray $collection ) #foreach ($child in $collection) array("${child.name}"=>array( #foreach($attr in $child.children) #if ( $attr.name == "path" || $attr.name == "link" ) "${attr.name}"=>"[system-asset]${attr.value}[/system-asset]" #else "${attr.name}"=>"${attr.value}" #end #if( $foreach.hasNext ),#end #end )) #if( $foreach.hasNext ),#end #end #end