DOM Funzioni
PHP Manual

dom_import_simplexml

(PHP 5)

dom_import_simplexml — Ottiene un'oggetto DOMElement da un'oggetto SimpleXMLElement

Descrizione

DOMElement dom_import_simplexml ( SimpleXMLElement $node )

Questa funzione prende il nodo node della classe SimpleXML e lo converte in un nodo DOMElement. Questo nuovo oggetto può essere utilizzato come nodo DOMElement nativo.

Elenco dei parametri

node

Il nodo SimpleXMLElement.

Valori restituiti

Il nodo DOMElement aggiunto oppure FALSE in caso di errore.

Esempi

Example #1 Importare SimpleXML nel DOM con dom_import_simplexml()

<?php

$sxe 
= simplexml_load_string('<books><book><title>blah</title></book></books>');

if (
$sxe === false) {
    echo 
'Error while parsing the document';
    exit;
}

$dom_sxe = dom_import_simplexml($sxe);
if (!
$dom_sxe) {
    echo 
'Error while converting XML';
    exit;
}

$dom = new DOMDocument('1.0');
$dom_sxe = $dom->importNode($dom_sxe, true);
$dom_sxe = $dom->appendChild($dom_sxe);

echo 
$dom->saveXML();

?>

Vedere anche:


DOM Funzioni
PHP Manual