...

View Full Version : Resolved simplexml help



anarchoi
11-14-2012, 09:00 AM
$apiurl = "http://api.spreadshirt.com/api/v1/shops/266497/articles/10568005";
$feed = simplexml_load_file($apiurl);
$items = $feed->article;
foreach ($items as $article) {
$feeddesign = $article->product->defaultValues->defaultDesign[id];
echo $feeddesign;
}

why isn't it working :(

Labrar
11-14-2012, 10:01 AM
article has no parent node.
Try this


<?php
$apiurl = "http://api.spreadshirt.com/api/v1/shops/266497/articles/10568005";
$feed = simplexml_load_file($apiurl);
$items = $feed;

foreach ($items as $article =>$val) {

if(strlen(trim($val))==0){
echo '<b><u>'.$article.'</u></b><br>';
echo '<pre>'; print_r($items->$article); echo '</pre>';
}else{
echo '<b>'.$article.'</b> = '.$val.'<br>';
}
}
echo '<b>This is what you need</b> '.$items->product->defaultValues->defaultDesign[id];
?>

anarchoi
11-14-2012, 10:15 AM
Thanks a lot :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum