Xml service by bns26590

VIEWS: 28 PAGES: 1526

									                                                                      Xml service manual - of
                                                                                    s.liza.cz and sks.liza.cz manual

Verze 3.4 z 26.10.2009 EN

Support center

CZ and SK version
Item list CZ
Item list SK

Search
Property detail
Fulltext search (flat)
30km circle around point designated by gps coordinates

Merge
Merge two items
Merge two districts

Comparation
Newer than 11.10.2005 00:00:00
Older than 11.10.2005 00:00:00
Price between 1M and 100M

Sort
Sort by time - ascending
Sort by price - descending

Paging ad utilities
All parameters can be combinated
Page: 10 items per page, starting on 5 (5-15)
3 items per page - testing purposes
output charset, for example utf-8

Podrobne informace
Property detail

Vyhledavani podle okresu
Vrati okresy ve kterych rk inzeruje (popsáno dále)

Vypis makléřů
Vrátí seznam makléřů (popsáno dále)

Fotografie a loga
original dimensions
with dimensions
with dimensions and background color
Agency logo
Broker photo
* If session defines items only one branch, parameter branch_id is not necessary.

Fulltext search
flats only
pouze novostavby bytu
pouze novostavby bytu
pouze byty - bud novostavby nebo cihlove, tj. byty AND (novostavba OR cihlovy)
tj. byty AND NOT panel AND (novostavba OR cihlovy)
hvezdicka zde funguje jako oznaceni skupiny moznych slov, kdy alespon jedno z nich musi byt nalezeno
                             Xml service manual - offers
                                           s.liza.cz and sks.liza.cz manual



                    http://coje.lojza.cz


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30
                    http://sks.liza.cz/Services/Datafetch.aspx?session=skweb&branch_id=30


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&ref_id=39
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&fulltext=flat
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&xy=[xr]30|11211|5459


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&ref_id=[in]39|41
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&district_id=[in]3610|3702|3602


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&last_refresh_time=[gt]20051011000000
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&last_refresh_time=[lt]20051011000000
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&ref_price=[bw]100000|100000000


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&sort=[aa]insert_time
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&sort=[dd]ref_price


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&last_refresh_time=[gt]20051011000000
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&limitfrom=5&step=10
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&step=3
                    http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=30&charset=utf-8


                    http://s.liza.cz/Services/DatafetchDetail.aspx?session=web&template=detail&branch_id=30&ref_id=39


                    http://s.liza.cz/Services/BranchDistricts.aspx?branch_id=1006


                    http://s.liza.cz/Services/DatafetchBroker.aspx?session=heslo&branch_id=30


                     http://s.liza.cz/Services/Imagefetch.ashx?id=632637078804531250
                     http://s.liza.cz/Services/Imagefetch.ashx?id=632637078804531250-400x300
                     http://s.liza.cz/Services/Imagefetch.ashx?id=632637078804531250-400x300-ffffee
                     http://s.liza.cz/Display/BranchLogoDisplay.ashx?id=6033-3006-A0F806E516571575D7A10D1BAD8F605C
                     http://s.liza.cz/Display/UserPhotoDisplay.ashx?id=6104-3006-B15EB8BEAFB9E7CE18F158C7EA50643F
ch, parameter branch_id is not necessary.


                    http://s.liza.cz/Services/Datafetch.aspx?session=web&step=10&fulltext=byty
                     http://s.liza.cz/Services/Datafetch.aspx?session=web&step=10&fulltext=byty novostavba
                     http://s.liza.cz/Services/Datafetch.aspx?session=web&step=10&fulltext=byty *novostavba
                     http://s.liza.cz/Services/Datafetch.aspx?session=web&step=10&fulltext=byty *novostavba *cihlovy
                     http://s.liza.cz/Services/Datafetch.aspx?session=web&step=10&fulltext=byty -panel *novostavba *cihlovy
upiny moznych slov, kdy alespon jedno z nich musi byt nalezeno
                                                            XML output - example
                                             http://s.liza.cz/Services/DatafetchDetail.aspx?session=web&template=det


    <?xml version="1.0" encoding="utf-8" ?>
  <database>
  <control>
    <status>success</status>
    <total_count>49</total_count>
    <from_count>1</from_count>
    <to_count>1</to_count>
  </control>
  <data>
  <row>
    <ref_id>385</ref_id>
    <target_code_prefix>H</target_code_prefix>
    <target_code_number>00105</target_code_number>
    <target_code>H-00105</target_code>
   <photo_hash>7461-3006-A729DFCC30116EB72EA6CEA0CF80553A</photo_hash>
    <branch_id>29</branch_id>
    <bus_type_id>1</bus_type_id>
    <category_id>6</category_id>
    <district_id>3709</district_id>
    <district_name>Prostějov</district_name>
    <city_id>508209</city_id>
    <city_name>Rovinka</city_name>
    <street>Císařská</street>
    <formatted_price>1.080.000 Kč</formatted_price>
    <price>1080000</formatted_price>
    <ref_price>1080000</ref_price>
    <ref_price_per_meter>10485</ref_price_per_meter>
    <area>17</area>
    <price_note />
    <caption>Flats for Sale in Litovel, Litovel, district of Olomouc</caption>
    <public_description>Flats intended for sale located on the street nám. Svobody in the municipality Li
    <insert_time>20051010124330</insert_time>
    <last_refresh_time>20051018160232</last_refresh_time>
  <images>
  <control>
    <status>success</status>
    <total_count>4</total_count>
  </control>
  <data>
  <row>
    <sequence_order>1</sequence_order>
    <file_id>632648016031250000</file_id>
    <description />
  </row>
  <row>
    <sequence_order>2</sequence_order>
    <file_id>632648017470937500</file_id>
    <description />
  </row>
  <row>
    <sequence_order>3</sequence_order>
    <file_id>632648025929062500</file_id>
    <description />
  </row>
  <row>
    <sequence_order>4</sequence_order>
    <file_id>632648026767187500</file_id>
    <description />
  </row>
  </data>
  </images>
  </row>
  </data>
  </database>
L output - example
/DatafetchDetail.aspx?session=web&template=detail&branch_id=30&ref_id=39




eet nám. Svobody in the municipality Litovel, district Olomouc. Street nám. Svobody. is located in the land register Litov
ody. is located in the land register Litovel…...</public_description>
                                        Available items depends on categories




                                                                                        Buildings (2)
                                                                                        Commercial
                                                                  Property (1)




                                                                                                                                                            Property (5)
                                                                  Agricultural




                                                                                                                                                            Historical
                                                                                                                                         Flats (4)
                                                                                                                   Lots (3)
Available items depends on
                                          Item name
         categories




                                                                                 Rent




                                                                                                        Rent




                                                                                                                              Rent




                                                                                                                                                     Rent
                                                                  Sale




                                                                                        Sale




                                                                                                               Sale




                                                                                                                                     Sale




                                                                                                                                                            Sale
sr_ownership                 ownership                                                                                               x               x
sr_building_type             building type                        x         x           x          x                                 x               x      x
sr_building_condition        building condition                   x         x           x          x                                 x               x      x
sr_floors                    floors in object                     x         x           x          x                                 x               x      x
sr_floor_number              floor number                                                                                            x               x
sr_underground_floors        underground floors                                                                                      x               x
sr_plot_area                 plot area                            x         x           x          x                                                        x
sr_commercial_kind           commercial kind                                            x          x
sr_total_area                total area                                                 x          x           x              x
sr_parking                   parking positions                                          x          x                                 x               x      x
sr_engineering_networks      engineering networks (from 0 to 3)                                                x              x
sr_flat_kind                 flat kind                                                                                               x               x
sr_floor_area                total floor area                                                                                        x               x
sr_building_area             building area                        x         x           x          x                                                        x
sr_usable_area               usable area                          x         x                                                                               x
sr_object_kind               object kind
sr_object_type               object type
sr_hotel_kind                hotel kind
sr_office_kind               office kind
sr_offices_area              offices area
sr_object_location           object location
recreation_type              recreation type
equiped                      equiped                                                                                                                 x
sr_flat_facilities1          elevator                                                                                                x               x
sr_balcony_area              balcony area                                                                                            x               x
sr_loggie_area               loggie area                                                                                             x               x
sr_terrace_area              terraces area                                                                                           x               x
sr_cellar_area               cellar area                                                                                             x               x
nt_elektrina_poznamka        electricity note                                                                  x              x
nt_plyn_poznamka             gas note                                                                          x              x
nt_kanalizace_poznamka       gutter note                                                                       x              x
nt_voda_poznamka             water note                                                                        x              x
toswimming                   swimming pool/lake distance
toskiing                     lift distance
togolf                       golf court distance
tocenter                     city center distance
sr_road_type                 road type                                                                         x              x
sr_heating                   heating
sr_acceptance_year           acceptance year
sr_reconstruction_year       reconstruction year
sr_estate_kind               lots kind                                                                         x              x
nemo_location                lots location                                                                     x              x
nemo_development             lots development                                                                  x              x
nemo_terrene                 lots terrene                                                                      x              x
ends on categories


                                                   restaurants (7)


                                                                            Block of Flats




                                                                                                                    Cottages and

                                                                                                                    Property (10)


                                                                                                                                     Constructions,
                                                                                                    Premises (9)


                                                                                                                    Recreational
                                                                                                    Commercial
                               Houses and
         Property (5)




                                                                                                                                     Garages (11)
                                                                                                    Offices and
         Historical




                                                   Hotels or
                               Vilas (6)



                                                                                                                                                            type




                                                                                                                                     Small
                                                                            (8)
                        Rent




                                            Rent




                                                                     Rent




                                                                                             Rent




                                                                                                             Rent




                                                                                                                              Rent




                                                                                                                                                 Rent
                               Sale




                                                   Sale




                                                                            Sale




                                                                                                     Sale




                                                                                                                      Sale




                                                                                                                                      Sale
                                                                                                                                                        counter
                   x           x        x          x            x           x           x            x       x       x       x       x          x       counter
                   x           x        x          x            x           x           x            x       x                       x          x       counter
                   x                               x            x           x           x                                                               integer
                                                                                                                                                        integer
                                                                                                                                                        integer
                   x           x        x          x            x           x           x                            x       x                          integer
                                                                                                                                                        counter
                                                                                                                                                        integer
                   x           x        x                                   x           x            x       x                                          integer
                                                                                                                                                        0/1
                                                                                                                                                        counter
                                                                                                                                                        integer
                   x           x        x          x            x           x           x                            x       x       x          x       integer
                   x           x        x          x            x           x           x                                                               integer
                               x        x                                                                                            x          x       counter
                               x        x                                                                                                               counter
                                                   x            x                                                                                       counter
                                                                                                     x       x                                          counter
                                                                                                     x       x                                          integer
                                                                                                                     x       x                          counter
                                                                                                                     x       x                          counter
                                                                                                                                                        counter
                                                                                                                                                        0/1
                                                                                                                                                        integer
                                                                                                                                                        integer
                                                                                                                                                        integer
                               x        x                                                                                                               integer
                                                                                                                     x       x                          text
                                                                                                                     x       x                          text
                                                                                                                     x       x                          text
                                                                                                                     x       x                          text
                                                                                                                     x       x                          counter
                                                                                                                     x       x                          counter
                                                                                                                     x       x                          counter
                                                                                                                     x       x                          counter
                                                                                                                     x       x                          counter
                               x        x                                                                            x       x                          counter
                               x                                                                                     x       x                          integer
                               x                                                                                     x       x                          integer
                                                                                                                                                        counter
                                                                                                                                                        counter
                                                                                                                                                        counter
                                                                                                                                                        counter
                                                                   Counters definitions
region_id     name                                              category_id
        19    Hl. m. Praha / Praha capital city                      1
      116     Brněnský kraj / Brno region                            2
        35    Českobudějovický kraj                                  3
        94    Pardubický kraj /Pardubice region                      4
        86    Královéhradecký kraj / Hradek Kralove region           5
      108     Vysočina / Highlands region                            6
        51    Karlovarský kraj / Karlovy Vary region                 7
        78    Liberecký kraj / Liberec region                        8
      124     Olomoucký kraj / Olomouc region                        9
        43    Plzeňský kraj / Plzeň region                          10
        27    Středočeský kraj / Middlebohemian region              11
      132     Moravskoslezský kraj / Moraviasilesian region
        60    Ústecký kraj / Usti nad Labem region            price_currency_id
      141     Zlínský kraj / Zlin region                              1
                                                                      2
district_id                      district_name
  3703        Brno - venkov / Brno - country                    price_unit_id
  3701        Blansko                                                 1
  3702        Brno - město / Brno - city                              2
  3704        Břeclav                                                 3
  3706        Hodonín                                                 4
  3712        Vyškov                                                  5
  3713        Znojmo                                                  6
  3301        České Budějovice
  3302        Český Krumlov                                     sr_flat_kind
  3303        Jindřichův Hradec                                       1
  3305        Písek                                                   2
  3306        Prachatice                                              3
  3307        Strakonice                                              4
  3308        Tábor                                                   5
  3603        Chrudim                                                 6
  3606        Pardubice                                               7
  3609        Svitavy                                                 8
  3611        Ústí nad Orlicí                                         9
  3602        Hradec Králové                                         10
  3604        Jičín                                                  11
  3605        Náchod                                                 12
  3607        Rychnov nad Kněţnou                                    13
  3610        Trutnov                                                14
  3601        Havlíčkův Brod                                         15
  3707        Jihlava                                                16
  3304        Pelhřimov                                              17
  3710        Třebíč                                                 18
  3714        Ţďár nad Sázavou
  3402        Cheb                                              sr_ownership
  3403        Karlovy Vary                                           1
3409   Sokolov                          2
3501   Česká Lípa                       3
3504   Jablonec nad Nisou
3505   Liberec                       equiped
3608   Semily                           1
3811   Jeseník                          2
3805   Olomouc                          3
3808   Přerov
3709   Prostějov            sr_engineering_networks0
3809   Šumperk              sr_engineering_networks1
3401   Domaţlice            sr_engineering_networks2
3404   Klatovy              sr_engineering_networks3
3406   Plzeň - jih                      0
3405   Plzeň - město                    1
3407   Plzeň - sever
3408   Rokycany                sr_commercial_kind
3410   Tachov                         1
3202   Beroun                         2
3201   Benešov                        3
3205   Kutná Hora                     4
3203   Kladno                         5
3204   Kolín                          6
3207   Mladá Boleslav                 7
3206   Mělník
3208   Nymburk                    sr_hotel kind
3211   Příbram                         1
3212   Rakovník                        2
3209   Praha - východ                  3
3210   Praha - západ
3801   Bruntál              sr_building_condition
3802   Frýdek-Místek                     1
3803   Karviná                           2
3804   Nový Jičín                        3
3806   Opava                             4
3807   Ostrava                           5
3503   Chomutov                          6
3502   Děčín                             7
3507   Louny                             8
3506   Litoměřice                        9
3508   Most
3509   Teplice                    sr_object_kind
3510   Ústí nad Labem                   1
3708   Kroměříţ                         2
3711   Uherské Hradiště                 3
3810   Vsetín                           4
3705   Zlín
3101   Praha 1                    sr_object_type
3102   Praha 2                          1
3103   Praha 3                          2
3104   Praha 4
3105   Praha 5                  sr_object_location
3106   Praha 6                          1
  3107        Praha 7                                             2
  3108        Praha 8                                             3
  3109        Praha 9                                             4
  3110        Praha 10                                            5
                                                                  6
region_id name                                                    7
         1 Bratislavský kraj / Bratislava region                  8
         2 Trnavský kraj / Trnava region
         3 Trenčiansky kraj / Trencin region               sr_building_type
         4 Nitriansky kraj / Nitra region                          1
         5 Ţilinský kraj / Zilina region                           2
         6 Banskobystrický kraj / Banska Bystrica region           3
         7 Prešovský kraj / Presov region                          4
         8 Košický kraj / Kosice region                            5
                                                                   6
district_id                     district_name                      7
   101        Bratislava I
   102        Bratislava II                                 sr_office_kind
   103        Bratislava III                                       1
   104        Bratislava IV                                        2
   105        Bratislava V                                         3
   106        Malacky                                              4
   107        Pezinok                                              5
   108        Senec
   201        Dunajská Streda                              nemo_location
   202        Galanta                                           1
   203        Hlohovec                                          2
   204        Piešťany
   205        Senica
   206        Skalica
   207        Trnava
   301        Bánovce nad Bebravou
   302        Ilava
   303        Myjava
   304        Nové Mesto nad Váhom
   305        Partizánske
   306        Povaţská Bystrica
   307        Prievidza
   308        Púchov
   309        Trenčín
   401        Komárno
   402        Levice
   403        Nitra
   404        Nové Zámky
   405        Šaľa
   406        Topoľčany
   407        Zlaté Moravce
   501        Bytča
   502        Čadca
   503        Dolný Kubín
   504        Kysucké Nové Mesto
   505        Liptovský Mikuláš
506   Martin
507   Námestovo
508   Ruţomberok
509   Turčianske Teplice
510   Tvrdošín
511   Ţilina
601   Banská Bystrica
602   Banská Štiavnica
603   Brezno
604   Detva
605   Krupina
606   Lučenec
607   Poltár
608   Revúca
609   Rimavská Sobota
610   Veľký Krtíš
611   Zvolen
612   Ţarnovica
613   Ţiar nad Hronom
701   Bardejov
702   Humenné
703   Keţmarok
704   Levoča
705   Medzilaborce
706   Poprad
707   Prešov
708   Sabinov
709   Snina
710   Stará Ľubovňa
711   Stropkov
712   Svidník
713   Vranov nad Topľou
801   Gelnica
802   Košice I
803   Košice II
804   Košice III
805   Košice IV
806   Košice - okolie
807   Michalovce
808   Roţňava
809   Sobrance
810   Spišská Nová Ves
811   Trebišov
ounters definitions
                        category_name
      Agricultural Property
      Commercial Buildings
      Lots
      Flats
      Historical Property
      Houses and Vilas
      Hotels or restaurants
      Block of Flats
      Offices and Commercial Premises
      Cottages and Recreational Property
      Small Constructions, Garages

                        price currency
      CZK/SKK
      EUR

                           price unit

      /m2
      /month
      /m2/month
      /rok
      /m2/year

                           flat type
      1+0
      1+kk /1,5 room / 1+kb
      2+kk /2,5 room / 2+kb
      3+kk /3.5 room / 3+kb
      4+kk /4.5 room / 4+kb
      5+kk /5.5 room / 5+kb
      6+kk /6,5 room / 6+kb
      7+kk /7,5 room / 7+kb
      1+1
      2+1
      3+1
      4+1
      5+1
      6+1
      7+1
      atypical
      other
      2+0 (SK only)

                          ownership
      private
cooperative
other

                      equiped
not furnished
half furnished
furnished

                       water
                       gutter
                        gas
                     electricity
no
yes

                  commercial_kind
storage
production
commercial centre
shooping centre
industrial premises
other
administration b.

                     hotel_kind
hotel
boarding-house
restaurant

                  building condition
very good
good
poor
under construction
project
new building
for housedemolishing
before reconstruction
after reconstruction

                   object location
down-the-line
at the corner
in block
individual

                     object type
ground floor
more floors

                   object location
city centre
quiet part
busy citypart
outskirts
estate housing
half singleness
singleness
cottage settlement (SK only)

                    building type
wooden
from bricks
stone made
prefabricated
panel
skeleton kind
mixed

                      office kind
offices
commercial
storage
other
manufacturing

                lots location (SK only)
intravilan
extravilan
                                                     Xml structure item definitio


   Item name                    Note                      type

target_code_number    property id prefix (agency)         integer
     target_code      property id postfix (agency)          text
        branch_id               agency id                 integer
      bus_type_id             operation id            counter, integer
      category_id             category id             counter, integer
        region_id               region id             counter, integer
        district_id             district id           counter, integer
     region_name             region name                    text
    district_name            district name                  text
       city_name               city_name                    text
          street                  street                    text
   formatted_price        preformatted price                text
           price                   price                    text
        ref_price                  price                  integer
ref_price_per_meter        price per meter                integer
        plot_area            area to price                integer
     is_exclusive           exclusiveness                 integer
       price_note            note to price                  text
         caption           property caption                 text
      description        property description               text
      insert_time              insert time                  date
  last_refresh_time          refresh time                   date
       (any other)                xitems                    text


                      Polozky obrazku
    Item name                   note                        type
  sequence_order           sequence_order                 integer
       file_id                image id                       text
    description              description                     text
Xml structure item definitions


                                       Available operations
             search =   enumeration =[in]   subrange =[bw]   camparation=[gt],[lt]
                x               x                                      x

                x               x
                x               x                                      x
                x               x                                      x
                x               x                                      x
                x               x                                      x




                x                                 x                    x
                x                                 x                    x
                x                                 x                    x
                                                  x                    x
                x               x



                                                                       x
                                                                       x
                x               x                 x                    x
ns
     sort =[aa],[dd]
            x


            x
            x
            x
            x
            x
            x
            x
            x

            x
            x
            x
            x




            x
            x
                                                                       Simple PHP5 parser

Parser using
                                                   date_default_timezone_set("Europe/Prague");
                                                   $libxml = new libxml();
                                                   $control = array();
Service url                                        $url = "http://s.liza.cz/Services/Datafetch.aspx?session=web&branch_id=3

Parse xml into php array                           $data = $libxml->fetchTableFromXMLFileSimple($url, &$control);

Example output - control statement                 print_r($control);
Example output - data                              print_r($data);
Example output - parsing time                      print_r($libxml->showbenchmark());


Libxml class necessary to use parser above

class libxml
{
            private $curl = false, $fetchstart = 0, $fetchend = 0, $parsestart = 0, $parseend = 0, $xmlcharset = "";

              function __construct() {
                         $this->curl = curl_init();
              }
              function __destruct() {
                         curl_close($this->curl);
              }

              // simple read and parse to array
              function fetchTableFromXMLFileSimple($url, &$control)
              {
                          $url = strip_tags($url);
                          $xml = $this->fetchfile($url);
                          if (strpos($xml, "/database") === false) return false;
                          return $this->parseresult($xml, $control);
              }

              function fetchfile($url) {
                          $file = '';
                          $this->fetchurl = $url;
                          $this->fetchstart = $this->microtime();
                          if (strtolower(substr($url, 0, 4)) == 'http') $file = $this->fetchremote($url);
                          else {
                                        if (is_readable($url)) $file = file_get_contents($url);
                          }
                          $this->fetchend = $this->microtime();
                          return trim($file);
              }

              function fetchremote($url)
              {
                          curl_setopt($this->curl, CURLOPT_TIMEOUT, 30);
             curl_setopt($this->curl, CURLOPT_URL, $url);
             curl_setopt($this->curl, CURLOPT_HEADER, 0);
             curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);

             return curl_exec($this->curl);
}

//////////////////
// parsing part //
//////////////////

function parseresult(&$xml, &$control)
{
           // bez elemetu databaze se ani nesnaz
           $pos = strpos($xml, "/database");
           if ($pos === false) return false;

             if($this->xmlcharset == ""){
                         ereg('encoding="([a-zA-Z0-9-]+)"', substr($xml, 0, 60), $x);
                         $this->xmlcharset = isset($x[1]) ? strtolower($x[1]) : false;
             }

             $array =& $this->parsetoarray($xml);

             $result = array();
             if ($array)
             {
                         if (isset($array['control'])) $control = $array['control'];
                         else $array['control']['total_count'] =0;

                         if (!isset($array['control']['from_count']) || $array['control']['from_count'] < 1) $array['con
                         if (!isset($array['control']['to_count'])) $array['control']['to_count'] = $array['control']['tot

                         $result = array();
                         if (!empty($array['data']['row']) && is_array($array['data']['row']))
                         {
                                     if (!isset($array['data']['row'][1]))
                                     {
                                                  // 1 radek
                                                  $result = array($array['data']['row']);
                                     }
                                     else
                                     {
                                                  // vic radku
                                                  $result =& $array['data']['row'];
                                     }
                         }
             }
             return $result;
}

function &parsetoarray(&$xml)
{
           $this->parsestart = $this->microtime();
           $sxml = simplexml_load_string($xml);
           $result = array();

           if ($sxml === false)
           return $result;

           foreach ($sxml as $atomname => $atom)
           {
                      $row = $this->parseatom($atom);
                      if ($row) $result[$atomname] = $row;
           }
           $this->parseend = $this->microtime();
           return $result;
}

function parseatom(&$atom)
{
           $return = array();
           if (is_array($atom)) {
                        foreach ($atom as $key => $value)
                        $return[$key] = $this->parseatom($atom[$key]);
           }

           else
           {
                       $var = get_object_vars($atom);
                       if ($var) {
                                   foreach($var as $key => $value)
                                   {
                                                if ($key == 'images' || $key == 'xitems')
                                                {
                                                             $x = get_object_vars($value);
                                                             // print_r($x); die;
                                                             $data = $x['data'];
                                                             $x = get_object_vars($data);
                                                             if (empty($x['row'])) $value = array();
                                                             elseif (isset($x['row'][1])) $value = $x['row'];
                                                             else $value = array($x['row']);
                                                }
                                                $return[$key] = $this->parseatom($value);
                                   }
                       }
                       else return trim((string) $atom);
           }
           return $return;
}

//////////////////
// benchmarking //
//////////////////

function showbenchmark() {
           $this->endtime = $this->microtime();
           return "XML fetched in ".round(($this->fetchend - $this->fetchstart)*1000, 4)."ms, parsed in ".roun
}
     function microtime() {
                list($usec, $sec) = explode(" ", microtime());
                return (float) $usec + (float) $sec;
     }

}
?>
mple PHP5 parser


_set("Europe/Prague");


ervices/Datafetch.aspx?session=web&branch_id=30";

ableFromXMLFileSimple($url, &$control);




estart = 0, $parseend = 0, $xmlcharset = "";




 $this->fetchremote($url);
substr($xml, 0, 60), $x);
 trtolower($x[1]) : false;




nt']) || $array['control']['from_count'] < 1) $array['control']['from_count'] = 0;
)) $array['control']['to_count'] = $array['control']['total_count'];


s_array($array['data']['row']))




ay($array['data']['row']);
mages' || $key == 'xitems')

$x = get_object_vars($value);


$x = get_object_vars($data);
f (empty($x['row'])) $value = array();
elseif (isset($x['row'][1])) $value = $x['row'];
else $value = array($x['row']);

y] = $this->parseatom($value);




d - $this->fetchstart)*1000, 4)."ms, parsed in ".round(($this->parseend - $this->parsestart)*1000, 4)."ms.\r\n\r\n";
                               Districts list (in theese actually agency ha
                                           http://s.liza.cz/Services/BranchDistricts.aspx?branch_id=1006




<database>
              <control>
                           <status>success</status>
                           <total_count>5</total_count>
              </control>
              <data>
                           <row>
                                           <branch_id>1006</branch_id>
                                           <district_id>3809</district_id>
                                           <district_name>Prostějov</district_name>
                                           <region_id>124</region_id>
                                           <job_count>63</job_count>
                           </row>
                           ... next 4x rows ...
              </data>
</database>
theese actually agency have items)
BranchDistricts.aspx?branch_id=1006




                               District Counts



                               Agency ID
                               District ID
                               District name
                               Region ID (parent category)
                               Items in district
                                                                  Brokers list
                                  http://s.liza.cz/Services/DatafetchBroker.aspx?session=heslo&branch_id=30



<?xml version="1.0" encoding="utf-8" ?>
<database>
           <control>
                       <status>success</status>
                       <total_count>15</total_count>
           </control>
            <data>
                       <row>

                                      <broker_id>65</broker_id>
                                      <branch_id>30</branch_id>
                                      <export_id>632637076657187500</export_id>
                                      <photo_hash>7461-3006-A729DFCC30116EB72EA6CEA0CF80553A</photo
                                      <firstname>Petr</firstname>
                                      <surname>Dewat</surname>
                                      <title/>
                                      <phone_main>284891616</phone_main>
                                      <phone_home/>
                                      <phone_mobile>733 536 653</phone_mobile>
                                      <fax>284891718</fax>
                                      <email>Petr.Dewat@DDreality.cz</email>
                                      <is_valid>1</is_valid>
                                      <icq />
                                      <skype/>
                                      <insert_time>20050930200910</insert_time>
                       </row>         <last_refresh_time>20081213182641</last_refresh_time>
                       ... next 14x rows …
          </data>
</database>
      Brokers list
afetchBroker.aspx?session=heslo&branch_id=30




                                                   Brokers in agency




657187500</export_id>
06-A729DFCC30116EB72EA6CEA0CF80553A</photo_hash>
                                                   Name
                                                   Surname

                                                   Phone

6 653</phone_mobile>

                                                   Email
                                                   Active record


200910</insert_time>
81213182641</last_refresh_time>

								
To top