将PHP输出为xml

时间:2014-03-22 16:23:31

标签: php xml

我正在处理我的PHP,因为我想获取get-listing.php中每个数组的链接列表。

我想得到每个数组的链接列表,如下所示:

http://testbox.elementfx.com/get-listing.php?channels=ABC FAMILY& id = 101 http://testbox.elementfx.com/get-listing.php?channels=CBS&id=102 http://testbox.elementfx.com/get-listing.php?channels=CNN USA& id = 103 http://testbox.elementfx.com/get-listing.php?channels=ESPN USA& id = 105 ..等等

我希望在PHP的每个链接上连接每个数组,以获取程序信息列表,以便在XML源代码中输出它们。

这是例如:

http://testbox.elementfx.com/get-listing.php

我想连接get-listing.php,我想连接get-listing.php中的每个链接,如cbs和cnn usa,然后我想获得访问以获取程序信息。

CBS节目信息:

<span id="time1">12:00 PM </span> - <span id="title1">2014 NCAA Basketball Tournament"Dayton vs. Ohio State - LIVE</span><br><br>
<span id="time2">2:30 PM </span> - <span id="title2">2014 NCAA Basketball Tournament"Western Michigan vs. Syracuse - LIVE</span><br><br>
<span id="time3">5:00 PM </span> - <span id="title3">Local Programming</span><br><br>
<span id="time4">6:00 PM </span> - <span id="title4">Local Programming</span><br><br>
<span id="time5">7:00 PM </span> - <span id="title5">2014 NCAA Basketball Tournament"Wofford vs. Michigan - LIVE</span><br><br>
<span id="time6">9:30 PM</span> - <span id="title6">2014 NCAA Basketball Tournament"Arizona State vs. Texas - LIVE</span><br><br>
<span id="time7">12:00 AM </span> - <span id="title7"> 1 Local Programming</span><br><br>
<span id="time8">12:35 AM </span> - <span id="title8">Late Show With David LettermanTV-PG  </span><br><br>
<span id="time9">1:37 AM </span> - <span id=title9>The Late Late Show With Craig FergusonTV-14  </span><br><br>

CNN节目信息:

<span id="time1">1:00 PM </span> - <span id="title1">Wolf</span><br><br>
<span id="time2">2:00 PM </span> - <span id="title2">CNN Newsroom</span><br><br>
<span id="time3">4:00 PM </span> - <span id="title3">The Lead With Jake Tapper</span><br><br>
<span id="time4">5:00 PM </span> - <span id="title4">The Situation Room</span><br><br>
<span id="time5">6:30 PM </span> - <span id="title5">Crossfire</span><br><br>
<span id="time6">7:00 PM </span> - <span id="title6">Erin Burnett OutFront</span><br><br>
<span id="time7">8:00 PM </span> - <span id="title7">Anderson Cooper 360</span><br><br>
<span id="time8">9:00 PM </span> - <span id="title8">Piers Morgan Live</span><br><br>
<span id="time9">10:00 PM </span> - <span id="title9">CNN Spotlight</span><br><br>

我想从<span id="title1<span id="title2<span id="title3等的每个标记中获取计划信息列表,以便为每个xml标记{{1}生成},<programme channel="CHANNEL NAME" start="s1" stop="e1">具有每个不同的开始和结束时间,然后在名为<programme channel="CHANNEL NAME" start="s2" stop="e2">的每个xml标记中输出程序标题。

XML的输出如下所示:

<title lang="en">

这是PHP脚本:

<?xml version="1.0" encoding="UTF-8" ?>
<tv generator-info-name="www.testbox.elementfx.com/xmltv">
<channel id="CBS">
   <display-name>CBS</display-name>
   <programme channel="CBS" start="s1" stop="e1">
       <title lang="en">2014 NCAA Basketball Tournament"Dayton vs. Ohio State - LIVE</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CBS" start="s2" stop="e2">
       <title lang="en">2014 NCAA Basketball Tournament"Western Michigan vs. Syracuse - LIVE</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CBS" start="s3" stop="e3">
       <title lang="en">Local Programming</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CBS" start="s4" stop="e4">
       <title lang="en">Local Programming</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
</channel> 

<channel id="CNN USA">
   <display-name>CNN USA</display-name>
   <programme channel="CNN USA" start="s1" stop="e1">
       <title lang="en">Wolf</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CNN USA" start="s2" stop="e2">
       <title lang="en">CNN Newsroom</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CNN USA" start="s3" stop="e3">
       <title lang="en">The Lead With Jake Tapper</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
   <programme channel="CNN USA" start="s4" stop="e4">
       <title lang="en">The Situation Room</title>
       <sub-title lang="en">sub title</sub-title>
       <desc lang="en">program description1</desc>
       <category lang="en">some category</category>
   </programme>
</channel> 
</tv>

请告诉我如何使用我的php源代码?

0 个答案:

没有答案