serializer, DOMDocument et XmlEncoder
bonjour à tous,
depuis deux jours je cherche comment modifié la balise initiale donnée lors de la sérialisation.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<?php
$request = Request::createFromGlobals();
$Platform=$request->query->get('platform');//paramètre guetter depuis l'url
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('BetappliApplicationBundle:Application')->findBy(array('platform'=>$Platform));
if($Platform=='android'||$Platform=='ios'||$Platform=='ipad')
{
foreach ($entity as $r) {
$em= $this->getDoctrine()->getEntityManager();
$build = $em->getRepository('BetappliApplicationBundle:Build')->findBy(array('application'=>$r->getId()));
foreach ($build as $b){
$xml[] =$b->toArray();//fonction définit pour associé chaque appl et son build 'relation entre ces deux entités'
}
}
$xml = $serializer->serialize(array('application'=>$xml), 'xml');
return new Response($xml);
}
else
{
$xml = $serializer->serialize(array('error' => $error), 'xml');
return new Response($xml);
}
?> |
si je fais $xml = $serializer->serialize($xml, 'xml'); j'obtient:
Code:
1 2 3 4 5 6 7 8 9
|
<response>
<item key="0">
................ 'mes fonctions appelées' toArray
</item>
<item key="1">
.................. 'mes fonctions appelées' toArray
</item>
</response> |
$xml = $serializer->serialize(array('application'=>$xml), 'xml');
Code:
1 2 3 4 5 6 7 8 9
|
<response>
<application>
................. 'mes fonctions appelées' toArray
</application>
<application>
................. 'mes fonctions appelées' toArray
</application>
</response> |
je n'ai pu modifie la balise <application> pour en avoir une balise <application Id= 'num de l'application'> et meme j'ai recherché au niveau de DOMDocument avec la creation de balise je n'ai pu atteindre mon objectif.
Est ce que vous avez une idée SVP?
Merci