-
-
Save ferdynator/644a0cfedea3c9072546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xml = new XMLReader(); | |
$xml->open('example.xml'); | |
while ($xml->read()) { | |
// elements only. skipp element end-tags and cdata etc | |
if ($xml->nodeType == XMLReader::ELEMENT) { | |
// process the Elements e.g. in a switch statement: | |
switch ($xml->name) { | |
case 'annuncio': | |
$cat = new SimpleXMLElement($xml->readOuterXML()); | |
$qry = 'INSERT INTO `annuncio`(id_annuncio, link, titolo, tipo_contratto, tipo_contratto, descrizione [...]) VALUES( | |
\'' . $cat->id_annuncio . '\', | |
\'' . $cat->link . '\', | |
\'' . $cat->titolo . '\', | |
\'' . $cat->tipo_contratto . '\', | |
\'' . $cat->tipo_contratto . '\', | |
\'' . $cat->descrizione . '\', | |
[...])'; | |
if (!mysql_query($qry)) { | |
die('Query failed!'); | |
} | |
unset($cat); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?XML version=“1.0” encoding=“UTF-8” ?> | |
<vortigo> | |
<annuncio> | |
<id_annuncio> <![CDATA[ . . . ]]> </id_annuncio> | |
<link> <![CDATA[ . . . ]]> </link> | |
<titolo> <![CDATA[ . . . ]]> </titolo> | |
<tipo_contratto> <![CDATA[ . . . ]]> </tipo_contratto> | |
<tipologia> <![CDATA[ . . . ]]> </tipologia> | |
<descrizione> <![CDATA[ . . . ]]> </descrizione> | |
<classe_energetica> <![CDATA[ . . . ]]> </classe_energetica> | |
<indice_energetica> <![CDATA[ . . . ]]> </indice_energetica> | |
<numero_stanze> <![CDATA[ . . . ]]> </numero_stanze> | |
<numero_bagni> <![CDATA[ . . . ]]> </numero_bagni> | |
<superficie> <![CDATA[ . . . ]]> </superficie> | |
<stato_immobile> <![CDATA[ . . . ]]> </stato_immobile> | |
<prezzo> <![CDATA[ . . . ]]> </prezzo> | |
<prezzo_giorno> <![CDATA[ . . . ]]> </prezzo_giorno> | |
<prezzo_settimana> <![CDATA[ . . . ]]> </prezzo_settimana> | |
<prezzo_scontato> <![CDATA[ . . . ]]> </prezzo_scontato> | |
<comune> <![CDATA[ . . . ]]> </comune> | |
<nazione> <![CDATA[ . . . ]]> </nazione> | |
<regione> <![CDATA[ . . . ]]> </regione> | |
<provincia> <![CDATA[ . . . ]]> </provincia> | |
<indirizzo> <![CDATA[ . . . ]]> </indirizzo> | |
<cap> <![CDATA[ . . . ]]> </cap> | |
<zona> <![CDATA[ . . . ]]> </zona> | |
<longitudine> <![CDATA [ . . . ]]> </longitudine> | |
<latitudine> <![CDATA[ . . . ]]> </latitudine> | |
<data_aggiornamento> <![CDATA[ . . . ]]> </data_aggiornamento> | |
<immagini> | |
<immagine> | |
<immagine_url> <![CDATA[ . . . ]]> </immagine_url> | |
<immagine_titolo> <![CDATA[ . . . ]]> </immagine_titolo> | |
</immagine> | |
<immagine> | |
<immagine_url> <![CDATA[ . . . ]]> </immagine_url> | |
<immagine_titolo> <![CDATA[ . . . ]]> </immagine_titolo> | |
</immagine> | |
</immagini> | |
<tipo_venditore> <![CDATA[ . . . ]]> </tipo_venditore> | |
<agenzia_nome> <![CDATA[ . . . ]]> </agenzia_nome> | |
<agenzia_comune> <![CDATA[ . . . ]]> </agenzia_comune> | |
<agenzia_email> <![CDATA[ . . . ]]> </agenzia_email> | |
<agenzia_url> <![CDATA[ . . . ]]> </agenzia_url> | |
<piscina> <![CDATA[ . . . ]]> </piscina> | |
<giardino> <![CDATA[ . . . ]]> </giardino> | |
<condizionatore> <![CDATA[ . . . ]]> </condizionatore> | |
<riscaldamento> <![CDATA[ . . . ]]> </riscaldamento> | |
<balcone> <![CDATA[ . . . ]]> </balcone> | |
<terrazzo> <![CDATA[ . . . ]]> </terrazzo> | |
<ascensore> <![CDATA[ . . . ]]> </ascensore> | |
<cucina> <![CDATA[ . . . ]]> </cucina> | |
<arredato> <![CDATA[ . . . ]]> </arredato> | |
<parcheggio> <![CDATA[ . . . ]]> </parcheggio> | |
<portale> <![CDATA[ . . . ]]> </portale> | |
<tipo_portale> <![CDATA[ . . . ]]> </tipo_portale> | |
<logo_portale> <![CDATA[ . . . ]]> </logo_portale> | |
</annuncio> | |
</vortigo> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment