This is my code so far… needless to say, it’s not working 🙁
$feed = <<< THEXML
<programs>
<program>
<date>2009-04-16</date>
<start_time>17:00</start_time>
<leadtext>hello hello!
</leadtext>
<name>Program 1</name>
<b-line>Comedy</b-line>
<synopsis>Funny stuff
</synopsis>
<url>http://www.domain.tld/program_name</url>
</program>
<programs>
THEXML;
$xml = (array) simplexml_load_string($feed);
print_r($xml);exit;
Would appreciate any help, have been around the php.net site for hours now and feeling braindead.
Please note that in the example xml above there is just one
<program>...</program>
tag, but in reality I have one or more of them that I need to use.
For example
<programs>
<program>...</program>
<program>...</program>
<program>...</program>
</programs>
I figured if I can get one to work then I can loop it, but just thought I would explain what I am going for here.
Thanks in advance!
Assuming the provider gives you valid XML, then you just have to iterate through the programs and use any information you need off it, like so:
Since you don’t have correct XML (being an unclosed
<programs>tag, then you might want to modify your script to correct that error like so: