Bonjour, j'ai un soucis que je n'arrive pas à corriger.

J'ai une fonction qui me génère une partie d'un flux xml à partir d'une réponse de webservice.

Cela fonctionne lorsque j'appelle ma fonction 3 ou 4 fois, mais dès que je veux appeler cette fonction 40, 50 ou 100x, j'ai de gros problème de mémoire.

Qu'est-ce que je peux optimiser pour avoir un fonctionnement correct?

Merci par avance pour vos réponses

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 
function genereArticle($filenameXml, $sousmenu_id)
{
	$i=1;
	$fluxXml = simplexml_load_file ($filenameXml);
 
	$fluxXml->registerXPathNamespace('blabla', 'http://dkhdkjhed/');
 
 
	foreach ($fluxXml->Resultats->Resultat as $articles)
	{
		$img =  $articles->xxxxx->xxxxxxx->xxxxx;
 
		if($sousmenu_id == '1111' || $sousmenu_id == '2222' || $sousmenu_id == '3333')
		{
			$periodeOuverture = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
		}
 
		$idArticle = $articles->dlijliud;
 
		$codePostal = $articles->dsfdffds->efdsdf->sdfsdfsd;
 
		$ville = $articles->dcscsdc->dkhkjds->dkuhkiuhsd;
 
		$adresse = $articles->sdkhukj->dkhkjs.' '.$articles->sqkjhkjd->sdqjkhkjhsq.' '.$articles->sqdlihjkjsd->dsjhkjhsd;
 
		$tel = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
 
		$mail = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
 
		$siteWeb = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
 
		$descriptionCourt = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
 
		$descriptionCom = $fluxXml->xpath("/xxx:xxxxx/xxxx:xxxxx/xxxx:xxxxx[".$i."]/xxx:xxxxxx/xxxx:xxxxxx[xxx:xxxxx= '16.02.49']/xxxx:xxxxxx");
 
		$latitude = str_replace(',', '.', $articles->Geolocalisations->Latitude);
 
		$longitude = str_replace(',', '.', $articles->Geolocalisations->Longitude);
 
																					//'.$maj.'
		$xml ='<ARTICLE priorite ="High" sousmenu_id="'.$sousmenu_id.'" maj="1">
		<SAISON>
		Toutes
		</SAISON> 
		<ADHERENT>1</ADHERENT> 
		<TITRE>
 
		<en>'.$titre.'</en>
		<fr>'.$titre.'</fr>
		</TITRE>
		<ID>'.$idArticle.$sousmenu_id.'</ID>
		<DESCRIPTION>
		<en><![CDATA['.$periodeOuverture[0].'<br/> '.$descriptionCourt[0].'<br/> '.$descriptionCom[0].'<br/><br/> '.$adresse.'<br/> '.$codePostal.' '.$ville.'<br/> '.$mail[0].'<br/><br/> '.$tel[0].'<br/><br/> '.$siteWeb[0].']]>
 
		</en>
		<fr> <![CDATA['.$periodeOuverture[0].'<br/>  '.$descriptionCourt[0].'<br/> '.$descriptionCom[0].'<br/><br/> '.$adresse.'<br/> '.$codePostal.' '.$ville.'<br/> '.$mail[0].'<br/><br/> '.$tel[0].'<br/><br/> '.$siteWeb[0].']]>
 
		</fr>
		</DESCRIPTION>
		<COMPTE_RENDU>
 
		<en>.</en>
		<fr>.</fr>
		</COMPTE_RENDU>
		<MOTS_CLEF>.</MOTS_CLEF>
		<ICONE></ICONE>
		<IMAGE></IMAGE>
		<DEBUT>01/09/2010 10:00</DEBUT>
		<FIN>01/09/2020 10:00</FIN>
		<LATITUDE>'.$latitude.'</LATITUDE>
		<LONGITUDE>'.$longitude.'</LONGITUDE>
		<ADRESS></ADRESS>
		<TEL></TEL>
		<SITE></SITE>
		</ARTICLE>';
 
		$i++;
	}
 
	return $xml;
}
 
$xml .= genereArticle("http://dkjhkhkdsjhk/khdkjhkjd/ksdjhkjd", 714);
 
$xml .= genereArticle("http://dkjhkhkdsjhk/khdkjhkjd/ksdjhkjd", 715);
 
$xml .= genereArticle("http://dkjhkhkdsjhk/khdkjhkjd/ksdjhkjd", 716);