I can echo the titles in the xml using the following code :
Code: Select all
if( ! $xml = simplexml_load_file('/path/to/my/file.xml') )
{
echo 'unable to load XML file';
}
else
{
foreach( $xml as $item )
{
//returns all the <title> from the xml file
$lc_title = $item->title;
echo $lc_title.'<br />';
}
}
Title One
Title Two
TitleThree etc...
So I can extract the titles in this way, but am not sure how to send those results in an email.
If I use mail() within the foreach statement and put in the message the variable $lc_title like this
Code: Select all
$to = "me@mymail.com";
$subject = "book titles";
$message = "The titles of the books are <br />".$lc_title."<br />";
$from = "server@mysite.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
I am not sure how to pass all the values in that foreach statement, out of it as a string to be used in my email.