Jump to content

Extracting data from particular attribute using simplexml


gnrmatt

Recommended Posts

Hi,

 

I have an XML Feed which is using ID's or Types. I need to select the specific node and convert it to a variable.

 

Example XML Feed:

 

<tour>
<tourName>Amazon Riverboat Adventure</tourName>
<dossierCode>PVIIA</dossierCode>
<tripDetails>
<tripDetail type="StartFinish">ex Lima</tripDetail>
<tripDetail type="What's Included">Lots of stuff </tripDetail>
</tripDetails>

 

I have been extracting this data by using:

 

<?php
if(!$xml=simplexml_load_file('xmlfeed.xml')){
    trigger_error('Error reading XML file',E_USER_ERROR);
}
foreach ($xml->tourName as $tourname)
foreach ($xml->dossierCode as $agentcode)
?>

 

However I am unsure how I can extract the "ex lima" from StartFinish as $startfinish.

 

Can anyone help?

 

Many thanks!

 

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.