Extract HTML value

2

I get the html and a part of it from where I need to extract the data and this one

         <td class="address-list-item">
    NOme silva    <div class="modal-content" style="display:none;">
        <div class="address-list-modal">
            <h2 class="title title-5">Excluir endereço</h2>
            <h3 class="title title-7">Deseja realmente excluir esse endereço?</h3>

            <div class="address-default-title">NOme</div>
            <div class="address-default-item">Rua  </div>
            <div class="address-default-item">CEP - SETOR </div>
            <div class="address-default-item">Cidade - Estado</div>

            <a onclick="deleteAddress(00000)" class="btn btn-9" "="" href="javascript::void(0)">Sim</a>
            <a onclick="clModal()" class="btn btn-9" href="javascript::void(0)">Não</a>
        </div>
    </div>
</td>
<td class="address-list-item">

    Rua  -
    cep - setor -
    Cidade - Estado
</td>
<td class="address-list-item">
    (00) 0000-0000    </td>
                        <td class="address-list-item is-last">
                            <a class="sel-link-edit-addicional-0000 address-list-item-link" href="/customer/address/edit/?address_id=000">
                                Editar                            </a>
                            <span class="bt_separator">|</span>
                            <a id="bt-delete-0000" class="address-list-item-link" href="javascript::void(0)" onclick="confirmationModal(this,0000)">
                                Excluir                            </a>
                        </td>
                    </tr>

I need to extract only the City - State

So I did my regex as well

    if (preg_match("#- (.*?) - \b[A-Z][A-Z]#", $this->http_response, $match))
    $estado = $match[0];

return $estado;

    
asked by anonymous 03.06.2015 / 08:09

1 answer

1

If the always field is formatted like this:

Rua  -
cep - setor -
Cidade - Estado

You can use the PHP function explode

$endereco = explode ( '-' , endereco );
$cidade = $endereco[2];
$estado = $endereco[3];

or javascript:

var endereco = document.querySelector(".address-list-item").innerHTML.split("-");
var rua = endereco[0];
var cep = endereco[1];
var cidade = endereco[2];
var estado = endereco[3];
    
03.06.2015 / 13:08