Hello,
How do I extract the URL from here with MagicParser?
<item>
<title>Amateur Radio Newsline Report #1511</title>
<description><img src="http://n5pre.podOmatic.com/2006-07-28T02_45_51-07_00.png" alt="itunes pic" /><br />News for the week in Amateur Radio for the week ending July 28, 2006</description>
<guid>http://n5pre.podOmatic.com/entry/2006-07-28T02_45_51-07_00</guid>
<comments>http://n5pre.podOmatic.com/entry/2006-07-28T02_45_51-07_00</comments>
<pubDate>Fri, 28 Jul 2006 09:45:52 GMT</pubDate>
<link>http://n5pre.podOmatic.com</link>
<dc:creator>AR Newsline</dc:creator>
<itunes:keywords>Amateur Radio,Newsline,News,Ham, Radio</itunes:keywords>
<enclosure length="4963788" url="http://n5pre.podOmatic.com/enclosure/2006-07-28T02_45_51-07_00.mp3" type="audio/mpeg"/>
<itunes:image href="http://n5pre.podOmatic.com/2006-07-28T02_45_51-07_00.png"/>
<itunes:block>no</itunes:block>
<itunes:explicit>clean</itunes:explicit>
<itunes:summary>News for the week in Amateur Radio for the week ending July 28, 2006</itunes:summary>
</item>
Thanks!
Hi There,
That XML segment looks like it is part of an RSS format feed, and so you would use it with Magic Parser using the format string "xml|RSS/CHANNEL/ITEM/".
To access the URL of the Podcast (which I assume is the URL attribute of the enclosure item); you would use the following code in your myRecordHandler function:
$url = $item["ENCLOSURE-URL"];
I've saved your XML above into a test file called podcast.xml, and written an example script to show how you would extract the URL:
Podcast Example
Here's the source code to that script:
<?php
require("MagicParser.php");
function myRecordHandler($item)
{
print $item["ENCLOSURE-URL"];
}
MagicParser_parse("podcast.xml","myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>
If the Podcast feed is not part of an RSS document, then you would do exactly as above except that you would use the Format String "xml|ITEM/".
Cheers!
David.