any suggestions on xml feed?
Moderator: General Moderators
any suggestions on xml feed?
i am a beginner of php and just now i started walking on php.Now i think i should make an xml reader.CAn i make that if yes how.I mean i want to get the rss feed from one site and read that and put that in my local pc.When i open my local site, it should read that xml feed and show it to me. how to go about it?
thanks for the guidance.
thanks for the guidance.
Have a look at this thread: viewtopic.php?t=36972
i tried that class but my browser does not say anything.
myReader.php
any idea why? I am behind a firewall and got user id and password to access remote sites.I am guessing that is the problem, but can not figureout how to go about it.
thanks
myReader.php
Code: Select all
<?php
include_once("studyParser.php");
$xml= new parser("http://www.mozilla.org/reorganization/feed.xml","XMLbasetag","XMLelement");
?>thanks
You need to replace "XMLbasetag" and "XMLelement" with the xml basetag and the XML base element.saumya wrote:i tried that class but my browser does not say anything.
myReader.phpany idea why? I am behind a firewall and got user id and password to access remote sites.I am guessing that is the problem, but can not figureout how to go about it.Code: Select all
<?php include_once("studyParser.php"); $xml= new parser("http://www.mozilla.org/reorganization/feed.xml","XMLbasetag","XMLelement"); ?>
thanks
For RSS try
Code: Select all
$rssFeed =new parser("http://www.mozilla.org/reorganization/feed.xml","ITEM","RSS");Code: Select all
echo'<H3>_$rssFeed->result</H3><XMP>';print_r($rssFeed->result);echo'</XMP>';using the code I've posted above
yields:
Code: Select all
include_once("class_xml_parser.inc.php");
$rssFeed =new parser("http://www.mozilla.org/reorganization/feed.xml","ITEM","RSS");
echo'<H3>_$rssFeed->result</H3><XMP>';print_r($rssFeed->result);echo'</XMP>';XML parsing result wrote: <H3>_$rssFeed->result</H3><XMP>Array
(
[-1] => Array
(
[TITLE] => Mozilla Foundation Reorganization
[LINK] => http://www.mozilla.org/reorganization/
[DESCRIPTION] => Blog links and posts related to the Mozilla Foundation's recent reorganization announcement.
)
[0] => Array
(
[TITLE] => Interview with Mitchell Baker at OSCON 2005 (Audio)
[DESCRIPTION] => MP3 podcast of interview with Mitchell Baker, President, Mozilla Corporation recorded at OSCON 2005.
[PUBDATE] => Thu, 04 Aug 2005 12:49:00 -0800
[LINK] => http://ftp.mozilla.org/pub/mozilla.org/ ... n-2005.mp3
)
[1] => Array
(
[TITLE] => Chris Blizzard - Mozilla Corporation
[DESCRIPTION] => Chris Blizzard, Board Member, Mozilla Corporation
[LINK] => http://www.0xdeadbeef.com/html/2005/08/#200508032005
[PUBDATE] => Wed, 03 Aug 2005 16:27:00 -0800
)
[2] => Array
(
[TITLE] => Tristan Nitot - Mozilla Foundation Reorganization
[DESCRIPTION] => Tristan Nitot, President, Mozilla Europe
[LINK] => http://standblog.org/blog/2005/08/03/93 ... ganization
[PUBDATE] => Wed, 02 Aug 2005 23:59:00 -0800
)
[3] => Array
(
[TITLE] => Karim Lakhani - Organizational Innovation: The Mozilla Corporation
[DESCRIPTION] => Karim Lakhani, Open Source Researcher, MIT
[LINK] => http://spoudaiospaizen.net/archives/200 ... rporation/
[PUBDATE] => Wed, 02 Aug 2005 23:59:00 -0800
)
[4] => Array
(
[TITLE] => Frank Hecker - The Mozilla Foundation Reorganization
[DESCRIPTION] => Frank Hecker, Director of Policy, Mozilla Foundation
[LINK] => http://www.hecker.org/mozilla/dot-reorg/
[PUBDATE] => Tue, 02 Aug 2005 23:59:00 -0800
)
[5] => Array
(
[TITLE] => Mitchell Baker - Organizing the Mozilla Project: Mozilla Corporation
[DESCRIPTION] => Mitchell Baker, President, Mozilla Corporation and Board Member, Mozilla Foundation
[LINK] => http://weblogs.mozillazine.org/mitchell ... the_1.html
[PUBDATE] => Tue, 02 Aug 2005 23:59:00 -0800
)
)
</XMP>
why my page does not show anything? i am doing something nonsense or missing out something
this does not show up anything.
Code: Select all
<?php
include_once("class_xml_parser.inc.php");
$rssFeed =new parser("http://www.mozilla.org/reorganization/feed.xml","ITEM","RSS");
echo'<H3>_$rssFeed->result</H3><XMP>';print_r($rssFeed->result);echo'</XMP>';
?>add
at the top of the file from where you include the class, run it and post the result.
Code: Select all
error_reporting (E_ALL);now my file lloks like this
but still browser is empty
Code: Select all
<?php
error_reporting (E_ALL);
include_once("class_xml_parser.inc.php");
$rssFeed =new parser("http://www.mozilla.org/reorganization/feed.xml","ITEM","RSS");
echo'<H3>_$rssFeed->result</H3><XMP>';print_r($rssFeed->result);echo'</XMP>';
?>you don't seem to be getting the rss-feed. Try
This checks whether the script is receiving the feed.
Code: Select all
$fp = fopen($file, "r");
while($data=fread($fp,4096)){
$xml[]=$data;
}
echo'<H3>_$xml</H3><XMP>';print_r($xml);echo'</XMP>';I've found http://magpierss.sf.net very useful
But you might want to solve your fetching remote data first... Meaby you ('re webhost) has been blocked by mozilla website because you fetch the file too many times in a given timeslot..
But you might want to solve your fetching remote data first... Meaby you ('re webhost) has been blocked by mozilla website because you fetch the file too many times in a given timeslot..
oops, replace $file with "http://www.mozilla.org/reorganization/feed.xml" in the first line of the script I posted above:
Code: Select all
$fp = fopen("http://www.mozilla.org/reorganization/feed.xml", "r");That might be the problem. Ask your IT-deparment how to run scripts fetching remote data.I am behind a firewall and got user id and password to access remote sites.
Code: Select all
<?php
//checking for feed
$file="http://www.mozilla.org/reorganization/feed.xml";
$fp = fopen($file, "r");
while($data=fread($fp,4096)){
$xml[]=$data;
}
echo'<H3>_$xml</H3><XMP>';
print_r($xml);
echo'</XMP>';
?>But then how the rss readers such as thunderbird gets data?!!
thanks a lot