Jump to content

Need help with parsing the contains


mark107

Recommended Posts

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">';
    ?>


 

 

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>


 

 

 

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>


 

 

 

 

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>


 

 

 

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?

Link to post
Share on other sites

the following is from the forum's rules for bumping your thread - 

 

If you bump, you must provide additional information. If you resort to bumping, chances are your question needs to be re-thought and re-described

 

 

no one has replied to this thread because it lacks definition and context. no one knows what the posted examples represent, what you have tried to solve this (the posted code in no way could be producing the output shown), and where you are stuck at in doing this.

 

next, if the examples are what is output from your own site, you would never parse the html to convert it to xml. you would take the raw data that's going into the html and produce the xml that you need from that data.

 

to get programming help, you need to post what the input data is, showing enough context and variation to pin down what is unique about that input, what the expected output from that input data is, and what output you are getting from your code (repeat for each different variation that the code must deal with.)

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.