a sample of XML file..
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="0.91">
<channel>
<title>rediff News: International</title>
<link>http://www.rediff.com/news/index.html</link>
<description>India's largest news and entertainment service online.</description>
<language>en-us</language>
<pubDate>Wed, 01 Feb 2006 12:06:04 GMT</pubDate>
<copyright>Copyright: (C) 2006 Rediff.com India Limited. All Rights Reserved.</copyright>
<image>
<title>rediff.com</title>
<url>http://www.rediff.com/uim/red_log.gif</url>
<link>http://www.rediff.com/</link>
<width>144</width>
<height>28</height>
<description>Visit rediff.com</description>
</image>
<!--01-02-2006:15:46:26-->
<item>
<title>My proposals on Kashmir are bold: Musharraf</title>
<link>http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01pak.htm</link>
<description>Musharraf said the proposals were bold and well considered in the context of finding a solution to the Kashmir issue, which would be acceptable to Pakistan, India and the people of Kashmir.</description>
</item>
<!--01-02-2006:13:16:52-->
<item>
<title>Bush stresses on fear factor</title>
<link>http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01bush.htm</link>
<description>The passion that he showed in speaking of these foreign policy issues, clearly seemed to dissipate when he got on to the domestic issues. </description>
</item>
<!--01-02-2006:09:57:51-->
<item>
<title>Coretta Scott King, widow of Martin Luther, dies</title>
<link>http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01king.htm</link>
<description>The 78-year-old widow of the celebrated champion of American Civil Rights movement passed away in Mexico overnight. </description>
</item>
<!--31-01-2006:18:00:12-->
<item>
<title>Indian national arrested in Philippines </title>
<link>http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31arrest.htm</link>
<description>Singh was allegedly one of the masterminds of a kidnapping syndicate that operated and victimised Indian nationals living in eastern Metropolitan Manila and Rizal province.</description>
</item>Code: Select all
<pre>
<?php
$input = file_get_contents("international.xml");
echo preg_match_all("#<link>.*?url=(.*?)</link>#si", $input, $matches)."<br />";
print_r($matches);
?>
</pre>Code: Select all
Array
(
[0] => Array
(
[0] => http://www.rediff.com/news/index.html
India's largest news and entertainment service online.
en-us
Wed, 01 Feb 2006 12:06:04 GMT
Copyright: (C) 2006 Rediff.com India Limited. All Rights Reserved.
http://www.rediff.com/uim/red_log.gif
http://www.rediff.com/
144
28
Visit rediff.com
http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01pak.htm
[1] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01bush.htm
[2] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/feb/01king.htm
[3] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31arrest.htm
[4] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31pak.htm
[5] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31mush.htm
[6] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31fulbright.htm
[7] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/31us.htm
[8] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/30iraq.htm
[9] => http://www.rediff.com/rss/redirect.php?url=http://www.rediff.com/news/2006/jan/30bhutto.htm
)
[1] => Array
(
[0] => http://www.rediff.com/news/2006/feb/01pak.htm
[1] => http://www.rediff.com/news/2006/feb/01bush.htm
[2] => http://www.rediff.com/news/2006/feb/01king.htm
[3] => http://www.rediff.com/news/2006/jan/31arrest.htm
[4] => http://www.rediff.com/news/2006/jan/31pak.htm
[5] => http://www.rediff.com/news/2006/jan/31mush.htm
[6] => http://www.rediff.com/news/2006/jan/31fulbright.htm
[7] => http://www.rediff.com/news/2006/jan/31us.htm
[8] => http://www.rediff.com/news/2006/jan/30iraq.htm
[9] => http://www.rediff.com/news/2006/jan/30bhutto.htm
)