Need help with parsing the contains

Discussion in 'PHP' started by mark103, Apr 4, 2014.

  1. #1
    Hi all,

    I'm working on my PHP to generating the xml output. I use simple_html_dom method to parsing the contains from my script called get-listing.php.


    Here is my PHP script:

        <?php
        ini_set('max_execution_time', 300);
        $errmsg_arr = array();
        $errflag = false;
        $link;
        include ('simple_html_dom.php');
       
        $base1 = "http://www.mysite.com/get-listing.php";
        $html = file_get_html($base1);     
           
        $countp = $html->find('p');       
        header("Content-type: text/xml");
        $xml .= "<?xml version='1.0' encoding='UTF-8' ?>";
        //echo $xml;
        $xml .= '<tv generator-info-name="www.testbox.elementfx.com/xmltv">';
        ?>
    Code (markup):

    Output for get-listing.php:

        <p id='channels'>ABC FAMILY</p><p id='links'><a href='http://www.mysite.com/get-listing.php?channels=ABC FAMILY&id=101'></p><a id="aTest" href="">Stream 1</a><br><br><p id='channels'>102 CBS</p><p id='links'><a href='http://www.mysite.com/get-listing.php?channels=CBS&id=102'></p><a id="aTest" href="">Stream 1</a><br><br>
    Code (markup):


    Here is the output for ABC-FAMILY:

        <span id="time1">9:00 PM </span> - <span id="title1">17 Again</span><br><br><span id="time2">11:00 PM </span> - <span id="title2">The 700 Club</span><br><br>
    Code (markup):



    Here is the output for CBS:

        <span id="time1">9:00 PM </span> - <span id="title1">Unforgettable: Til Death</span><br><br><span id="time2">10:00 PM </span> - <span id="title2">Hawaii Five-0: Ho'i Hou</span><br><br>
    Code (markup):


    I'm creating the variable so I can connect to get-listing.php script. I want to create the loops variable to get the list of url from get-listing.php with each html tag called `<p id="links">`. And also I want to get the list of contains from the get-listing.php when I open on each url. The contains I want to get from the tags is called `<span id="title1">` and `<span id="title2">`.

    Can you please tell me how I can create the loops to get the list of url from each tag `<p id='links'>` to open them using with `simple_html_dom` and how I can get the list of contains I want to get from abc-family and cbs output?
     
    mark103, Apr 4, 2014 IP