esiste un altro modo oppure dovrei evitare di usare dom
raga soo riuscito a cancellare i child e ricrearli ma non riesco a settare lo stile xslt a questa pagina xml aggiornata
Codice PHP:
<?php $doc = new DOMDocument; $doc->load('book.xml');
$book = $doc->documentElement;
// cancello il contenuto di nome e cognome
$chapter = $book->getElementsByTagName('nome')->item(0);
$oldchapter = $book->removeChild($chapter);
$chapter = $book->getElementsByTagName('cognome')->item(0);
$oldchapter = $book->removeChild($chapter);
//aggiungo il nuovo nome $add = $doc->createElement('nome');
$text = $doc->createTextNode('jim'); $add->appendChild($text);
$book->appendChild($add);
//aggiungo il nuovo cognome $add = $doc->createElement('cognome');
$text = $doc->createTextNode('morrison');
$add->appendChild($text);
$book->appendChild($add);
echo $doc->saveXML();
$xsl = new DomDocument;
$xsl->load('style.xslt');
$proc = new xsltprocessor();
$proc->importStyleSheet($xsl);
echo "
".($proc->transformToXML($doc));
?>
file xslt
codice:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<ul> [*] [/list]
</html>
</xsl:template>
</xsl:stylesheet>
dove sbalgio?