Função PHP __construct()
Definição e uso
A função __construct() cria um novo objeto SimpleXMLElement.
Se bem-sucedido, a função retorna um objeto. Se falhar, retorna false.
Sintaxe
__construct(data,options,is_url,ns,is_prefix)
Parâmetros | Descrição |
---|---|
data | Obrigatório. String XML bem formatada ou caminho do documento XML ou URL. |
options | Opcional. Determina os parâmetros adicionais do Libxml. |
is_url | Opcional. Determina se o parâmetro data é uma URL. O padrão é false. |
ns | Opcional. |
is_prefix | Opcional. |
Retorno
Retorna um objeto SimpleXMLElement que representa os dados.
Exemplo
<?php $xmlstring = <<<XML <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note> XML; $xml = new SimpleXMLElement($xmlstring); echo $xml->body[0]; ?>
Saída semelhante a:
Não se esqueça da reunião!