Hi, I use this script to extract and insert the desired variables to mysql.It does the job.
$xml = new SimpleXMLElement('file.xml');
foreach($xml->loanaccount as $mess){
$account_number= mysql_real_escape_string($mess->account_number);
$main= mysql_real_escape_string($mess->main);
$type= mysql_real_escape_string($mess->{'application-array'}->{'application-type'}),
$date= mysql_real_escape_string($mess->{'application-array'}->{'application-date'}),
//insert into databse
mysql_query("INSERT INTO account (account_number, main) VALUES ('$account_number', '$main')")
or die(mysql_error());
echo "inserted into mysql<br /><br />";
//show updated records
printf ("Records inserted: %d\n", mysql_affected_rows());
}
The problem I have is that the xml can contain several application-array and I need to insert the application-date and application-type from the most recent application-array.
This is what the xml looks like.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<account-information report-date="2012-12-31T23:59:59.000+01:00" xmlns="http://www.XXX.SE/XXX">
<account>
<account-number>00000000</account-number>
<status>XXX</status>
<application-array>
<application-type>NEW</application-type>
<application-date>XXX</application-date>
</application-array>
<application-array>
<application-type>TOP</application-type>
<application-date>XXX</application-date>
</application-array>
<account-information-type>
<first-name-main></first-name-main>
</account-information-type>
</account>
</account-information>
So how do I change my foreach statement to capture the most recent application-type and date from the application array.
Thanks
Adamski