I'm trying to parse xml result with php (DOM) :
stdClass Object
(
[GetBilletResult] => Array
(
[0] => stdClass Object
(
[tabGrilleHoraire] => stdClass Object
(
[tabDetailTarifArticle] => stdClass Object
(
[sNomArticle] => ARTICLE1
[tabDetail] => Array
(
[0] => stdClass Object
(
[sDetail] => Liste Pax [Âge:19]
[sAgePax] => 19;
...
)
[1] => stdClass Object
(
[sDetail] => Prix de Base
[sAgePax] => 18;
...
)
My code so far:
$processed = array();
foreach( $billets as $GetBilletResult )
{
$sNomProduit = $GetBilletResult->getElementsByTagName( "sNomProduit" )->item(0)->nodeValue;
$sNomArticle = $GetBilletResult->getElementsByTagName( "sNomArticle" )->item(0)->nodeValue;
$tabDetail = $GetBilletResult->getElementsByTagName( "tabDetail" );
if (!isset($processed[$sNomProduit])) {
$processed[$sNomProduit] = array();
}
$processed[$sNomProduit][] = array(
'sNomArticle' => $sNomArticle,
'tabDetail' => $tabDetail,
);
}
The loop to display the results (articles are regrouped by product):
foreach ($processed as $sNomProduit => $list) {
echo "<h3> ".$sNomProduit."</h3>";
foreach ($list as $item) {
echo "<h5> ".$item['sNomArticle'] . "</h5>";
foreach ($item['tabDetail'] as $node) {
var_dump ($node->nodeValue);
}
}
}
Output (The arrays under "tabDetail" array are displayed as strings)
PRODUIT A
ARTICLE A1
string 'Liste Pax : Pax n°1 [Âge:19]19;ADULTE(12-59.99)00000' (length=54)
string 'Prix de Base240300000' (length=21)
...
var_dump, is that intentional? Don't you just wantecho?var_dumpto check the result type. Replace it byechodoesn't fix the problem.