<?xml version="1.0" encoding="UTF-8"?>
<listings>
    <title>https://{{$.Header.dominio}}</title>
    {{range .Imoveis}}
    <listing>
        {{if index . "fotos"}}{{raw (index . "fotos")}}{{end}}
        <home_listing_id>{{index . "referencia"}}</home_listing_id>
        <availability>{{index . "transacao"}}</availability>
        <url>https://{{$.Header.dominio}}{{index . "url_anuncio"}}</url>
        <name><![CDATA[{{index . "titulo"}}]]></name>
        {{if index . "price"}}<price>{{index . "price"}}</price>{{end}}
        {{if index . "property_type"}}<property_type>{{index . "property_type"}}</property_type>{{end}}
        <address format="simple">
            {{if index . "endereco"}}<component name="addr1">{{raw (index . "endereco")}}</component>{{end}}
            {{if index . "complemento"}}<component name="addr2">{{raw (index . "complemento")}}</component>{{end}}
            {{if index . "bairro"}}<component name="addr3">{{raw (index . "bairro")}}</component>{{end}}
            {{if index . "numero"}}<component name="unit_number">{{index . "numero"}}</component>{{end}}
            <component name="city">{{raw (index . "cidade")}}</component>
            {{if index . "city_id"}}<component name="city_id">{{index . "city_id"}}</component>{{end}}
            <component name="region">{{index . "estado"}}</component>
            {{if index . "province"}}<component name="province">{{index . "province"}}</component>{{else}}<component name="province"/>{{end}}
            {{if index . "cep"}}<component name="postal_code">{{index . "cep"}}</component>{{end}}
            <component name="country">Brasil</component>
        </address>
        {{if and (index . "latitude") (index . "longitude")}}
        <latitude>{{index . "latitude"}}</latitude>
        <longitude>{{index . "longitude"}}</longitude>
        {{end}}
        {{if index . "bairro"}}
        <neighborhood><![CDATA[{{raw (index . "bairro")}}]]></neighborhood>
        {{else}}
        <neighborhood><![CDATA[{{raw (index . "cidade")}}]]></neighborhood>
        {{end}}
    </listing>
    {{end}}
</listings>
