gnrmatt Posted May 9, 2011 Share Posted May 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235921-php-simplexml-help/ Share on other sites More sharing options...
gnrmatt Posted May 9, 2011 Author Share Posted May 9, 2011 Sorry - Resolved myself. For reference: <?php if(!$xml=simplexml_load_file('http://bookedy:[email protected]/api/feeds/tours/PVIIA/')){ trigger_error('Error reading XML file',E_USER_ERROR); } foreach ($xml->tourName as $tourname){ echo $tourname; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/235921-php-simplexml-help/#findComment-1212787 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.