Parse External XML File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
uswebpro
Forum Newbie
Posts: 1
Joined: Sun Jan 18, 2004 5:42 pm

Parse External XML File

Post by uswebpro »

I want to display data from this XML Document

http://xml.amazon.com/onca/xml3?t=jwubo ... age=&f=xml


Should I parse it straight into the my PHP page, or make an XSLT and inclue that?

I was trying to just parse it, but I need a little help.
I saw alot of sample scripts, but only for local xml files.
I know that I need to start off like:
$filename = "sample.xml";
So can I do something like:
$filename = (getURL)"http://dsaasd.com/sample.xml";

Thanks!
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Re: Parse External XML File

Post by scorphus »

uswebpro wrote:So can I do something like:
$filename = (getURL)"http://dsaasd.com/sample.xml";
Sure! [php_man]file_get_contents[/php_man]() is you best friend:

Code: Select all

<?php
$xml_text = file_get_contents('http://dsaasd.com/sample.xml');
?>
[php_man]file_get_contents[/php_man]() is only available on PHP 4 >= 4.3.0 though.

Regards,
Scorphus.
Post Reply