Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: simplexml help

  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    93
    Thanks
    4
    Thanked 0 Times in 0 Posts

    simplexml help

    Code:
    $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
    Last edited by anarchoi; 11-14-2012 at 11:15 AM.

  • #2
    New Coder
    Join Date
    Jun 2008
    Posts
    62
    Thanks
    0
    Thanked 12 Times in 12 Posts
    article has no parent node.
    Try this
    PHP Code:
    <?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];
    ?>
    Last edited by Labrar; 11-14-2012 at 11:03 AM.

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    93
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks a lot


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •