Accessing a URL
Hi All,
I'm not a programmer these days (been years since I have and since
become a lawyer... don't hate me) but a friend asked for a favour and
it's been a while since I cracked out even a basic piece of code so I
said ok.
Anyhow, this script needs to read an RSS feed at the following extremely
long and annoying URL. From what I can work out )my friend didn't know
either) it's a PHP script that publishes the data as an RSS feed. The
URL is as follows.
http://www.mylegalcareer.com.au/content.php/jobresults.html? form_search_e
mployerid=&form_search_employer_label=&form_search_locality= &form_search_
state=&form_search_employertype%5B%5D=&form_search_jobtype%5 B%5D=&form_se
arch_practice%5B%5D=&form_search_jobcategory%5B%5D=&form_sub mit_x=24&form
_submit_y=11&form_submit=Submit&rss=1
Now I've written a small script which essentially reads the output from
that script (which I saved into a file for testing) and prints out the
<title> and <link> elements as a new webpage. The ultimate goal is the
actively feed off the RSS feed and present it in a nice HTML form in an
iframe (which will be used on several websites).
So my question (after my long winded explanation) is how do I access
this data via it's URL? I can't seem to work it out.
The code is as follows.
<?php
if(!$xml=simplexml_load_file('test.xml')){
trigger_error('Error reading XML file',E_USER_ERROR);
}
for ($x = 0; $x<9; $x++) {
echo '<a href=' . $xml->channel[0]->item[$x]->link . '>'.
$xml->channel[0]->item[$x]->title . '</a><br>';
}
?>
Thanks in advance for any help you can give me... it's been a fun
challenge to even get to this point.
Re: Accessing a URL
On 1 Feb, 09:08, SirFlibble <nospample... [at] garbagetodel.flibbled.com>
wrote:
> Hi All,
>
> I'm not a programmer these days (been years since I have and since
> become a lawyer... don't hate me) but a friend asked for a favour and
> it's been a while since I cracked out even a basic piece of code so I
> said ok.
>
> Anyhow, this script needs to read an RSS feed at the following extremely
> long and annoying URL. From what I can work out )my friend didn't know
> either) it's a PHP script that publishes the data as an RSS feed. The
> URL is as follows.
>
> http://www.mylegalcareer.com.au/content.php/jobresults.html? form_sear...
> mployerid=&form_search_employer_label=&form_search_locality= &form_search_
> state=&form_search_employertype%5B%5D=&form_search_jobtype%5 B%5D=&form_se
> arch_practice%5B%5D=&form_search_jobcategory%5B%5D=&form_sub mit_x=24&form
> _submit_y=11&form_submit=Submit&rss=1
<snip>
> Thanks in advance for any help you can give me... it's been a fun
> challenge to even get to this point.
IANAL...
You don't say what's not working.
Depending on the config of your PHP install, your code might niot be
able to read directly from a web page. You can test this with:
<?php
print file('http://.....');
?>
If its a problem parsing the XML - there's a lot of code available off
the shelf for handling RSS - I've used Magpie RSS and found it easy.
C.
Re: Accessing a URL
On 1 Feb, 09:08, SirFlibble <nospample... [at] garbagetodel.flibbled.com>
wrote:
> Hi All,
>
> I'm not a programmer these days (been years since I have and since
> become a lawyer... don't hate me) but a friend asked for a favour and
> it's been a while since I cracked out even a basic piece of code so I
> said ok.
>
> Anyhow, this script needs to read an RSS feed at the following extremely
> long and annoying URL. From what I can work out )my friend didn't know
> either) it's a PHP script that publishes the data as an RSS feed. The
> URL is as follows.
>
> http://www.mylegalcareer.com.au/content.php/jobresults.html? form_sear...
> mployerid=&form_search_employer_label=&form_search_locality= &form_search_
> state=&form_search_employertype%5B%5D=&form_search_jobtype%5 B%5D=&form_se
> arch_practice%5B%5D=&form_search_jobcategory%5B%5D=&form_sub mit_x=24&form
> _submit_y=11&form_submit=Submit&rss=1
>
> Now I've written a small script which essentially reads the output from
> that script (which I saved into a file for testing) and prints out the
> <title> and <link> elements as a new webpage. The ultimate goal is the
> actively feed off the RSS feed and present it in a nice HTML form in an
> iframe (which will be used on several websites).
>
> So my question (after my long winded explanation) is how do I access
> this data via it's URL? I can't seem to work it out.
>
> The code is as follows.
>
> <?php
> if(!$xml=simplexml_load_file('test.xml')){
> trigger_error('Error reading XML file',E_USER_ERROR);
> }
> for ($x = 0; $x<9; $x++) {
> echo '<a href=' . $xml->channel[0]->item[$x]->link . '>'.
> $xml->channel[0]->item[$x]->title . '</a><br>';
> }
> ?>
>
> Thanks in advance for any help you can give me... it's been a fun
> challenge to even get to this point.
I thought lawyers had to be very careful with their grammar when
writing legal documents so that they should not be misinterpreted?
("it's URL" should be "its URL")
Anyway, you can use CURL or you may (as long as the server is
configured to allow it - i.e. allow_url_fopen is enabled), be able to
just put the URL into an fopen() call.