simplxml load help

Discussion in 'PHP' started by gamingedge, Feb 13, 2011.

  1. #1
    Really new to coding and ran into trouble trying to set up an XML feed. I know it's probably really easy and I have searched many tutorials but I keep receiving errors when adding the codes. The feed I'm trying to setup can be found at http://www.pokeraffiliatesolutions.com/docs/xmlfeeds.php.

    Now the code I used to load the feed was

    <?php

    if( ! $xml = simplexml_load_file('http://rakeback.thepokerdream.net/feeds/poker_rooms/cake-poker.xml') )
    {
    echo 'unable to load XML file';
    }
    else
    {
    echo 'XML file loaded successfully';
    }
    ?>

    Now that I've loaded the code, I'm lost as to what to do next.
     
    gamingedge, Feb 13, 2011 IP
  2. moads

    moads Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Try opening it up locally like this...

    $xml = simplexml_load_file('cake-poker.xml')

    If it's not on your server just fopen() it.. save it to your server, then load it locally.
     
    moads, Feb 13, 2011 IP
  3. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What to do next really depends on what you want to do with the xml file once you have loaded it.

    At the moment, running the script will simply tell you if the file was loaded or not.

    What happens when you run the script? Does it load the file or not, or, does it give you an error.

    Knowing this would help with suggestions of what to do next...
     
    mallorcahp, Feb 14, 2011 IP
  4. gamingedge

    gamingedge Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Loads fine, after inputting the code, it displays the msgs, Load Successful
     
    gamingedge, Feb 15, 2011 IP
  5. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Assuming you want to output the feed you have just loaded, you need to change the header and send. If this is part of another file, make sure there is not output before you change the header or you will get an error.

    Try this :

    <?php

    if( ! $xml = simplexml_load_file('http://rakeback.thepokerdream.net/feeds/poker_rooms/cake-poker.xml') )
    {
    echo 'unable to load XML file';
    }
    else
    {
    header ("content-type: text/xml");
    echo $xml;
    }
    ?>
     
    mallorcahp, Feb 17, 2011 IP