2
I have a real estate system and with it I developed my own XML standard for integration with Portals.
But the code that I use to read my XML, can not do the reading that is in the pattern of Viva Real.
Here is an example of the Viva Real pattern:
<ListingDataFeed xsi:schemaLocation="http://www.vivareal.com/schemas/1.0/VRSync">
<Header>
<PublishDate>2016-04-07T11:32:06</PublishDate>
<Provider>Agencia ArteDB</Provider>
<Email>[email protected]</Email>
<ContactName>Joaci Brito</ContactName>
<Telephone>(11) 982013467</Telephone>
<Logo>http://artedb.com.br/images/logo.png</Logo>
</Header>
<Listings>
<Listing>
<ListingID> 006</ListingID>
<Featured>true</Featured>
<ListDate>2016-01-21T01:51:08</ListDate>
<LastUpdateDate>2016-01-21T01:51:08</LastUpdateDate>
<TransactionType>For Sale</TransactionType>
<Title>Sobrado - Venda - Alvorada </Title>
<Location>
<Country abbreviation="BR">Brasil</Country>
<State abbreviation="SP">São Paulo</State>
<City>Guarulhos</City>
<Neighborhood>Alvorada </Neighborhood>
<PostalCode>07000-000</PostalCode>
<Zone>Zona Leste</Zone>
<Url>http://www.brunaalbuquerqueimoveis.com.br/detalharimovel.php?imovel=52d96ce4cba0c7.93798</Url>
<Latitude>-23.4444658</Latitude>
<Longitude>-46.4153649</Longitude>
</Location>
<Details>
<Description>Sobrado :: 3 Dorm. ( sendo um suite, mais dois dorm. um com sacada + banheiro para auxiliar os dormitórios solteiros), sala ( dois ambientes), lavabo, copa/cozinha, área de serv.no fundo coberta com amplo espaço no fundo para lazer + 2 vagas de garagem. Bairro com Toda Infraestrutura, proximo a escolas, farmácias, padaria e hospital, fácil acesso as avenidas principais e rodovia Presidente Dutra. :: Obs.: Aceita Financiamento Pela Caixa Econômica ou qualquer outro banco de sua preferencia
</Description>
<ListPrice currency="BRL">350000</ListPrice>
<PropertyAdministrationFee currency="BRL">0</PropertyAdministrationFee>
<PropertyType>Residential / Home</PropertyType>
<ConstructedArea unit="square metres">0</ConstructedArea>
<Bedrooms>3</Bedrooms>
<Bathrooms>2</Bathrooms>
<Suites>1</Suites>
<Garage type="Parking Space">2</Garage>
<LotArea unit="square metres">0</LotArea>
<Features/>
</Details>
<Media>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab120776a80.01.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab499d69c19.05.jpg</Item><Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab5af593342.20.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab71461d604.66.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab8088f8392.44.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab8e877d475.37.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ab976adf8f1.69.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ababd986a19.88.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535abb3c3b2420.52.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535abe736cb462.06.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ac10e808778.82.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ac28431e507.25.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ac3686a7c20.81.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ac46ee16e91.39.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535ac8b0944b01.72.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535acb37dae581.87.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535af0cf037f16.70.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535af2e7b68645.33.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535af56bc1aa27.12.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535af6b0bbc383.26.jpg</Item>
<Item medium="image">http://eclipse.artedb.com.br/arquivos/img2/IMO535af8354bb722.99.jpg</Item>
</Media>
<ContactInfo>
<Email>[email protected]</Email>
<Name>Imobiliária Nova União</Name>
<Telephone>2087-0293</Telephone>
<Website>brunaalbuquerqueimoveis.com.br</Website>
<Location>
<Country abbreviation="BR">Brasil</Country>
<State>SP</State>
</Location>
</ContactInfo>
<Status>
<PropertyStatus>Available</PropertyStatus>
<StatusDate>2016-01-21T01:51:08</StatusDate>
</Status>
</Listing>
</ListingDataFeed>
Now follows the PHP code I use to read the XML I developed within my standard and that works perfectly, but does not capture the XML fields that is in the pattern of Viva Real above:
$xml = file_get_contents('roteirodoimovel.xml');
// transformar o XML em um objeto
$sxml = new SimpleXMLElement($xml);
// iteracao por todo o XML:
foreach ($sxml as $linhaAtual) {
// obter cada item do xml referente ao campo da tabela
// cast porque a propriedade do objeto
// tambem é um objeto do tipo SimpleXMLElement
$id = (int) $linhaAtual->id;
$goal = (int) $linhaAtual->goal;
$idimv = (int) $linhaAtual->idimv;
$url = (string) $linhaAtual->url;
$urlimovel = (string) $linhaAtual->urlimovel;
$agency_name = (string) $linhaAtual->agency_name;
$agency_email = (string) $linhaAtual->agency_email;
$logo = (string) $linhaAtual->logo;
$type = (string) $linhaAtual->type;
$property_type = (string) $linhaAtual->property_type;
$title = (string) $linhaAtual->title;
$content = (string) $linhaAtual->content;
$rooms = (int) $linhaAtual->rooms;
$bathrooms = (int) $linhaAtual->bathrooms;
$parking = (int) $linhaAtual->parking;
$floor_area = (string) $linhaAtual->floor_area;
$price = (int) $linhaAtual->price;
$region = (string) $linhaAtual->region;
$city = (string) $linhaAtual->city;
$country = (string) $linhaAtual->country;
$neighborhood = (string) $linhaAtual->neighborhood;
$address = (string) $linhaAtual->address;
$picture_url = (string) $linhaAtual->picture_url;
What to do to make him read the patterns of Viva Real?