Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

55 users online



Syndicating XML data into a website using PHP...

Syndicating XML data into a website using PHP...

Currently viewing this thread: 1 (0 members and 1 guests)


Jackal05

Jackal05

Neverside Newbie
Status: Offline!

Syndicating XML data into a website using PHP...

Ok, let's say we have the following XML document located at www.anothersite.com/rss.xml

Code:

<rss version="2.0">
<channel>
<item1>Something</item1>
<item2>Something else</item2>
<item1>Some data</item1>
</channel>
</rss>


Now I wanna syndicate some (items 1 and 3) of that information into my own site.
I have proficient PHP skills and I know that it is possible to use PHP to display data like that on a website. Can someone tell me how to?
Using PHP I wanna turn each tag in the XML file into a variable then include that on the site. All I need to know is how to get a tag from the XML document displayed on a HTML document.

To break it down let's say I wanna have a small box on my site like:
Just some info:
- Item One: Something
- Item Three: Some data
Using the data from the XML document.

Thanks. Wink

aonic

aonic

Neversidian
Status: Offline!

http://www.phpfreaks.com/tutorials/44/1.php

___________________

-Developer
-Forum Leader
-NeverNET

danielmccoy

danielmccoy

Status: Offline!

You could take the easy way out and use ereg:

PHP:

<?php

eregi
("<item1 *>([^<>]*)</item1 *>",$textfilecontents,$echome);

?>

That should work, just use fopen to get the contents of the XML file.

___________________

Game servers, need one? CS, CZ, DOD danieljmccoy@hotmail.com

rallyrulz

rallyrulz

rally fan
Status: Offline!

You need a php rss aggregator, i used one the other week for a site i did. Basically there is a big complex class that does all the dirty work for you, and you just parse it a URL and call its functions like get title etc, then you can format it yourself. The reason i would recomend doing it this way is there are many rss variaties and syntaxes, sometimes there are even errors, so the class will either validate it or give you the correct string.

Ill try to track the link for it down now, if i dont find it just try to google for rss php aggregator

Edit: found it here http://magpierss.sourceforge.net/

Last edited by rallyrulz, July 8th, 2004 04:09 PM (Edited 1 times)

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0077 seconds.