Omschrijving_lang = utf8_decode($Woning->Omschrijving_lang);
En de
kun je omzetten naar whitespace met:
$Woning->Omschrijving_lang = nl2br($Woning->Omschrijving_lang);
*/
$objecten = simplexml_load_file($xml);
foreach ($objecten ->Woning as $Woning) {
/* Op deze wijze zijn de gegevens uit te lezen:
$Woning['id']
$Woning->Straatnaam;
$Woning->Huisnummer;
$Woning->Postcode;
$Woning->Woonplaats;
$Woning->Provincie;
$Woning->Land;
$Woning->Vraagprijs;
$Woning->PrijsType;
$Woning->Status;
$Woning->Omschrijving_kort;
$Woning->Omschrijving_lang;
$Woning->Type;
$Woning->AantalWoonlagen;
$Woning->Bouwjaar;
$Woning->AantalKamers;
$Woning->AantalSlaapkamers;
$Woning->AantalBadkamers;
$Woning->WoonOppervlakte;
$Woning->TotaleInhoud;
$Woning->PerceelOppervlakte;
$Woning->Balkon;
$Woning->Garage>;
$Woning->Tuin;
$Woning->Bijgebouwen;
$Woning->Schuur;
$Woning->Ligging;
$Woning->Aanvaarding;
$Woning->Datum;
$Woning->SoortObject;
$Woning->Url;
$Woning->Energielabel;
$Woning->WatDoen;
Tonen in browser om te testen, kan dmv:*/
printf("ID: %s\n", $Woning['id']);
printf("Straatnaam: %s\n", $Woning->Straatnaam);
printf("Actie: %s\n", $Woning->WatDoen);
echo "
";
foreach ($Woning ->Fotos ->fotoURL as $fotoURL) { // alle foto's bij deze woning ophalen
$fotoURL;
printf("Foto: %s\n", $fotoURL);
/* Controleer of de woning al in uw database aanwezig is. Het beste is dit te doen op basis van
Straatnaam + Huisnummer + Woonplaats
-----------------------------------------------------------
-----------------------------------------------------------
OPTIE 1
De woning bestaat : update database met woning gegevens
-----------------------------------------------------------
-----------------------------------------------------------
*********************************************
***** update de woning database *************
*********************************************
Let op: Als de foto's veranderd zijn, dan komt de woning ook op aangepast te staan, dus bij
een update dient u ook de foto's opnieuw ophalen.
Voorbeeld hoe u foto's extern kunt ophalen en deze op uw eigen server kan plaatsen:
------------------------------
srand ((double) microtime( )*1000000);
$Nieuwenaam = rand(0,1200);
$pre = "_";
$thumb = "thumb_";
$uploaddir_relatief = "uwfotodir/";
$woningID = $Woning['id'];
$path_parts = pathinfo($fotoURL);
$Extensie = $path_parts['extension'];
/* foto extern ophalen
$image_attribs = getimagesize($fotoURL);
$im_old = imageCreateFromJpeg($fotoURL);
$th_max_width = 500;
$th_max_height = 300;
$ratio = ($height > $width) ? $th_max_height/$image_attribs[1] : $th_max_width/$image_attribs[0];
$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;
$im_new = imagecreatetruecolor($th_width,$th_height);
imageAntiAlias($im_new,true);
$th_file_name = $uploaddir_relatief . $woningID . $pre . $Nieuwenaam . '.' . $Extensie;
imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);
imageJpeg($im_new,$th_file_name,100);
/* en nu de thumbnail
$im_file_name = $uploaddir_relatief . $woningID . $pre . $Nieuwenaam . '.' . $Extensie;
$image_attribs = getimagesize($im_file_name);
$im_old = imageCreateFromJpeg($im_file_name);
$th_max_width = 100;
$th_max_height = 100;
$ratio = ($height > $width) ? $th_max_height/$image_attribs[1] : $th_max_width/$image_attribs[0];
$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;
$im_new = imagecreatetruecolor($th_width,$th_height);
imageAntiAlias($im_new,true);
$th_file_name = $uploaddir_relatief . $thumb . $woningID . $pre . $Nieuwenaam . '.' . $Extensie;
imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);
imageJpeg($im_new,$th_file_name,100);
******************************************************
***** insert of update de foto database **************
******************************************************
-------------------------------
*/
} // einde for each foto
// De gebruikersnaam is uniek en kan niet gewijzigd worden door de gebruiker
$Gebruikersnaam = $Woning ->Gebruiker ->Gebruikersnaam;
$Naam = $Woning ->Gebruiker ->Naam;
$Email = $Woning ->Gebruiker ->Email;
//echo "
gebruiker: $Gebruikersnaam, $Naam , $Email";
/*
********************************************************************************
***** als aparte gebruikers db - check of er geupdated moet worden *************
***** bijvoorbeeld als de gebruiker een nieuw Emailadres heeft *************
********************************************************************************
-----------------------------------------------------------
-----------------------------------------------------------
OPTIE 2
De woning bestaat nog niet in uw database: insert
-----------------------------------------------------------
-----------------------------------------------------------
************************************************
***** insert in de woning database *************
************************************************
Foto's ophalen.
************************************************
***** insert de foto database ******************
************************************************
************************************************
***** als aparte gebruikers db - insert ********
************************************************
-----------------------------------------------------------
-----------------------------------------------------------
OPTIE 3
De woning staat op verwijderd
-----------------------------------------------------------
-----------------------------------------------------------
************************************************
***** delete from de woning database ***********
************************************************
Foto's van uw server verwijderen.
************************************************
***** delete from foto database ****************
************************************************
Als aparte gebruikers database: heeft deze gebruiker
meerdere woningen? Zo nee, verwijder de gebruiker.
************************************************
***** als aparte gebruikers db - delete ********
************************************************
*/
}
?>