SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: XML With PHP

  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML With PHP

    I am trying to read XML file through PHP.here is my XML File http://www.goalserve.com/samples/soccer_livescore.xml
    And my PHP code is
    PHP Code:
    <?php
        $test 
    simplexml_load_file('http://www.goalserve.com/samples/soccer_livescore.xml');
        echo 
    $test->category["file_group"];
        
    ?>
    The output is england but how we get all content with loop like foreach loop

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by khubbaib View Post
    I am trying to read XML file through PHP.here is my XML File http://www.goalserve.com/samples/soccer_livescore.xml
    And my PHP code is
    PHP Code:
    <?php
        $test 
    simplexml_load_file('http://www.goalserve.com/samples/soccer_livescore.xml');
        echo 
    $test->category["file_group"];
        
    ?>
    The output is england but how we get all content with loop like foreach loop
    I've noticed simple xml can be a little finicky at times when iterating (forget the exact circumstance) but due to that I'd say just do the json trick:

    Code PHP:
    $test = json_decode(json_encode(simplexml_load_file('http://www.goalserve.com/samples/soccer_livescore.xml')), true);
    print_r($test);

    You should have a full array now that you can esily read and manipulate.

  3. #3
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks For help @K. Wolfe i just want to ask how i can get record on different page? For example i have player id,name match result on one page but i want to get all events for that match on second page here is my example file where all records shown on one page like goal,yellow card,red card i want to show on popup page for every match.


Tags for this Thread

Bookmarks

Posting Permissions

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