Page 1 of 1

Parse External XML File

Posted: Sun Jan 18, 2004 5:42 pm
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!

Re: Parse External XML File

Posted: Sun Jan 18, 2004 8:21 pm
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.