Jump to content

php simplexml help


gnrmatt

Recommended Posts

Hi,

 

I'm trying to get to grips with basic PHP SimpleXml so please accept my apologise if i'm doing something blatently stupid here.

 

I have an XML Feed as follows:

 

<tour>
<tourName>Amazon Riverboat Adventure</tourName>
<dossierCode>PVIIA</dossierCode>
<url>http://www.gapadventures.com/trips/amazon-riverboat-adventure/PVIIA/2011/</url>
<tripDescription>Hop aboard a riverboat and experience the Amazon in style. The cuisine onboard is regional and provides a unique—and delicious—window into local culture. Led by an Amazon Reserve Naturalist guide, your cruise will include daily excursions by motorized skiff designed to reveal the exotic wildlife that calls the rainforest home—with any luck you’ll spot sloths, toucans or pink dolphins! And, with two full days for exploration in Pacaya Samiria Reserve, you'll have the chance to experience the jungle up close. Gain a rare glimpse of how life ‘on the river‘ is lived and experience the magic of the Amazon on this once-in-a-lifetime riverboat adventure.</tripDescription>
<tripStyle>Classic</tripStyle>
</tour>

 

I want to get just the tour name from this so i have done:

 

<?php
// displays all the file nodes
if(!$xml=simplexml_load_file('xmlfeed.xml')){
    trigger_error('Error reading XML file',E_USER_ERROR);
}
// displays first user's name
echo 'Displaying Tour Name... <br />';
echo $xml->$tour[0]->tourName;
?>

 

However this fails to display the tourname for me. I'm sure it's something really stupid that i'm doing but any help is greatly appreciated!

 

Many thanks!

 

Matt

Link to comment
https://forums.phpfreaks.com/topic/235921-php-simplexml-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.