Latox
Latox

Reputation: 4705

open XML file and get certain content?

I have the following URL:

http://en.wikipedia.org/wiki/Special:Export/Birkdale,_Queensland

I want to get the following out of it:

pop      = 13,460 (2006 census)
lga      = Redland City
dist1    = 44
near-nw  = [[Thorneside, Queensland|Thorneside]]
| near-n   = 
| near-ne  = [[Wellington Point, Queensland|Wellington Point]]
| near-w   = [[Ransome, Queensland|Ransome]]
| near-e   = [[Wellington Point, Queensland|Wellington Point]]
| near-sw  = [[Capalaba West, Queensland|Capalaba West]]
| near-s   = [[Capalaba, Queensland|Capalaba]]
| near-se  = [[Alexandra Hills, Queensland|Alexandra Hills]]

I want to return them as variables, for example:

$pop = "13,460 (2006 census)";
$lga = "Redland City";
$distance = 44;
$nearnw = "Thorneside";
$nearn = "";
$nearne = "Wellington Point";
$nearw = "Ransome";
$neare = "Wellington Point";
$nearsw = "Capalaba West";
$nears = "Capalaba";
$nearse = "Alexandra Hills";

How would I go about extracting the information from this XML file and putting them into variables exactly like explained above?

Thank you.

Upvotes: 1

Views: 831

Answers (1)

Ibu
Ibu

Reputation: 43840

have you tried using simplexml

$url = "http://en.wikipedia.org/wiki/Special:Export/Birkdale,_Queensland";

$xml = simplexml_load_file($url);

Upvotes: 1

Related Questions