View Single Post
  #1 (permalink)  
Old 06-17-09, 11:03 AM
geny geny is offline
New Member
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Extracting from XML using PHP

Hi ,
There is this link -> http://data.giub.uni-bonn.de/openrou...tructions=true !

Where I want to extract 2 things (shown below in BOLD):
<xls:Instruction>Drive half left on Kaiserstraße</xls:Instruction>
<xls:distance value="284" uom="YD"/>

So,far I tried :
PHP Code:
$url="url_just_shown_above";
$output file_get_contents($url);
$xml simplexml_load_string($output);
echo 
$xml->{'xls:RouteInstruction'}->{'xls:Instruction'}."<br />";

but it does not helps, for attribute,I used :
$xml simplexml_load_file("url_just_shown_above");

foreach(
$xml->{'xls:distance[5]'}->attributes() as $a => $b)
  {
  echo 
$a,'="',$b,"\"</br>";
  } 
it shows nothing either.
The var_dump($xml); shows :
Code:
object(SimpleXMLElement)#1 (1) { ["@attributes"]=> array(1) { ["version"]=> string(3) "1.1" } }
Please help me extracting the BOLDed text from the XML file mentioned above..What wrong am I doing ? Any kind of guidance or CODE Snippet will be of great help..Will greatly appreciate the same.. Thanks a lot !

Last edited by Nico; 06-19-09 at 05:40 PM.
Reply With Quote