| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* XML_Serializer
|
|
|
4 |
*
|
|
|
5 |
* Creates XML documents from PHP data structures like arrays, objects or scalars.
|
|
|
6 |
*
|
|
|
7 |
* PHP versions 4 and 5
|
|
|
8 |
*
|
|
|
9 |
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
|
|
10 |
* that is available through the world-wide-web at the following URI:
|
|
|
11 |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
|
|
12 |
* the PHP License and are unable to obtain it through the web, please
|
|
|
13 |
* send a note to license@php.net so we can mail you a copy immediately.
|
|
|
14 |
*
|
|
|
15 |
* @category XML
|
|
|
16 |
* @package ImmoScout24Export
|
|
|
17 |
* @author Markus Niewerth <markus@weban.de>
|
|
|
18 |
* @copyright 1997-2007 The PHP Group
|
|
|
19 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|
|
20 |
* @version CVS: $Id: ImmoScout24Export.php,v 1.0 2007/09/27 9:45:30 markusniewerth Exp $
|
|
|
21 |
* @link http://pear.php.net/package/XML_Serializer
|
|
|
22 |
* @see XML_Unserializer
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
error_reporting(E_ALL ^ E_WARNING);
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Creates XML documents from PHP data structures like arrays, objects or scalars.
|
|
|
30 |
*
|
|
|
31 |
* this class can be used in two modes:
|
|
|
32 |
*
|
|
|
33 |
* 1. create an XML document from an array or object that is processed by other
|
|
|
34 |
* applications. That means, you can create a RDF document from an array in the
|
|
|
35 |
* following format:
|
|
|
36 |
*
|
|
|
37 |
* $data = array(
|
|
|
38 |
* 'channel' => array(
|
|
|
39 |
* 'title' => 'Example RDF channel',
|
|
|
40 |
* 'link' => 'http://www.php-tools.de',
|
|
|
41 |
* 'image' => array(
|
|
|
42 |
* 'title' => 'Example image',
|
|
|
43 |
* 'url' => 'http://www.php-tools.de/image.gif',
|
|
|
44 |
* 'link' => 'http://www.php-tools.de'
|
|
|
45 |
* ),
|
|
|
46 |
* array(
|
|
|
47 |
* 'title' => 'Example item',
|
|
|
48 |
* 'link' => 'http://example.com'
|
|
|
49 |
* ),
|
|
|
50 |
* array(
|
|
|
51 |
* 'title' => 'Another Example item',
|
|
|
52 |
* 'link' => 'http://example.org'
|
|
|
53 |
* )
|
|
|
54 |
* )
|
|
|
55 |
* );
|
|
|
56 |
*
|
|
|
57 |
* to create a RDF document from this array do the following:
|
|
|
58 |
*
|
|
|
59 |
* require_once 'XML/Serializer.php';
|
|
|
60 |
*
|
|
|
61 |
* $options = array(
|
|
|
62 |
* XML_SERIALIZER_OPTION_INDENT => "\t", // indent with tabs
|
|
|
63 |
* XML_SERIALIZER_OPTION_LINEBREAKS => "\n", // use UNIX line breaks
|
|
|
64 |
* XML_SERIALIZER_OPTION_ROOT_NAME => 'rdf:RDF', // root tag
|
|
|
65 |
* XML_SERIALIZER_OPTION_DEFAULT_TAG => 'item' // tag for values with numeric keys
|
|
|
66 |
* );
|
|
|
67 |
*
|
|
|
68 |
* $serializer = new XML_Serializer($options);
|
|
|
69 |
* $rdf = $serializer->serialize($data);
|
|
|
70 |
*
|
|
|
71 |
* You will get a complete XML document that can be processed like any RDF document.
|
|
|
72 |
*
|
|
|
73 |
* 2. this classes can be used to serialize any data structure in a way that it can
|
|
|
74 |
* later be unserialized again.
|
|
|
75 |
* XML_Serializer will store the type of the value and additional meta information
|
|
|
76 |
* in attributes of the surrounding tag. This meat information can later be used
|
|
|
77 |
* to restore the original data structure in PHP. If you want XML_Serializer
|
|
|
78 |
* to add meta information to the tags, add
|
|
|
79 |
*
|
|
|
80 |
* XML_SERIALIZER_OPTION_TYPEHINTS => true
|
|
|
81 |
*
|
|
|
82 |
* to the options array in the constructor.
|
|
|
83 |
*
|
|
|
84 |
* @category XML
|
|
|
85 |
* @package ImmoScout24Export
|
|
|
86 |
* @author Markus Niewerth <markus@weban.de>
|
|
|
87 |
* @copyright 1997-2007 The PHP Group
|
|
|
88 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|
|
89 |
* @version CVS: $Id: ImmoScout24Export.php,v 1.0 2007/09/27 9:45:30 markusniewerth Exp $
|
|
|
90 |
* @link http://pear.php.net/package/XML_Serializer
|
|
|
91 |
* @see XML_Unserializer
|
|
|
92 |
*/
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
$tags = array(
|
|
|
96 |
|
|
|
97 |
"IS24ImmobilienTransfer" => array (
|
|
|
98 |
"xmlns" => "http://www.immobilienscout24.de/immobilientransfer",
|
|
|
99 |
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
|
|
100 |
"xsi:schemaLocation" => "http://www.immobilienscout24.de/immobilientransfer is24immotransfer.xsd",
|
|
|
101 |
"ErstellerSoftware" => "ImmoScout24Export",
|
|
|
102 |
"ErstellerSoftwareVersion" => "1.0",
|
|
|
103 |
"EmailBeiFehler" => "markus@weban.de"
|
|
|
104 |
),
|
|
|
105 |
"Anbieter" => array (
|
|
|
106 |
"ScoutKundenID" => "30302"
|
|
|
107 |
),
|
|
|
108 |
"WohnungMiete" => array (
|
|
|
109 |
"AnbieterObjektID" => "0815",
|
|
|
110 |
"Ueberschrift" => "Schöne Wohnung" ,
|
|
|
111 |
"Importmodus" => "importieren" ,
|
|
|
112 |
"Wohnflaeche" => "100.00" ,
|
|
|
113 |
"Zimmer" => "4.00" ,
|
|
|
114 |
"Adressdruck" => "true" ,
|
|
|
115 |
"AnzahlBadezimmer" => "2" ,
|
|
|
116 |
"AnzahlSchlafzimmer" => "2" ,
|
|
|
117 |
"Aufzug" => "true" ,
|
|
|
118 |
"BalkonTerrasse" => "true" ,
|
|
|
119 |
"Baujahr" => "1869" ,
|
|
|
120 |
"BetreutesWohnen" => "true" ,
|
|
|
121 |
"Einbaukueche" => "true" ,
|
|
|
122 |
"Etage" => "2" ,
|
|
|
123 |
"Etagenzahl" => "6" ,
|
|
|
124 |
"Foerderung" => "true" ,
|
|
|
125 |
"FreiAb" => "sofort" ,
|
|
|
126 |
"GartenBenutzung" => "true" ,
|
|
|
127 |
"GruppierungsID" => "1" ,
|
|
|
128 |
"Haustiere" => "nachVereinbarung" ,
|
|
|
129 |
"Heizungsart" => "Zentralheizung" ,
|
|
|
130 |
"Nutzflaeche" => "22" ,
|
|
|
131 |
"Objektzustand" => "Gepflegt" ,
|
|
|
132 |
"Parkplatz" => "true" ,
|
|
|
133 |
"Provision" => "3.8% zzg. 16%MSt" ,
|
|
|
134 |
"Rollstuhlgerecht" => "true" ,
|
|
|
135 |
"StatusHP" => "aktiv" ,
|
|
|
136 |
"StatusIS24" => "aktiv" ,
|
|
|
137 |
"StatusVBM" => "aktiv" ,
|
|
|
138 |
"Waehrung" => "EUR" ,
|
|
|
139 |
"WohnungKategorie" => "Etagenwohnung"
|
|
|
140 |
)
|
|
|
141 |
);
|
|
|
142 |
|
|
|
143 |
require_once 'XML/Query2XML.php';
|
|
|
144 |
require_once 'MDB2.php';
|
|
|
145 |
|
|
|
146 |
$query2xml = XML_Query2XML::factory(MDB2::factory('mysql://gwg_gladbeck_de:g-w7-a@localhost/gwg_gladbeck_de'));
|
|
|
147 |
|
|
|
148 |
$dom = $query2xml->getXML(
|
|
|
149 |
"SELECT * FROM directory",
|
|
|
150 |
array(
|
|
|
151 |
'rootTag' => 'IS24ImmobilienTransfer',
|
|
|
152 |
'idColumn' => 'ID',
|
|
|
153 |
'rowTag' => 'WohnungMiete',
|
|
|
154 |
'elements' => array(),
|
|
|
155 |
'attributes' => array(
|
|
|
156 |
'name' => "Name",
|
|
|
157 |
'Bild' => "bild_url",
|
|
|
158 |
'Stati' => 'status'
|
|
|
159 |
)
|
|
|
160 |
)
|
|
|
161 |
);
|
|
|
162 |
|
|
|
163 |
//header('Content-Type: application/xml');
|
|
|
164 |
$dom->formatOutput = true;
|
|
|
165 |
print $dom->saveXML();
|
|
|
166 |
|
|
|
167 |
?>
|