Hi i want to modify an xml with php in a server. I hace the n
<?php
$idFiesta = $_POST['idFiesta'];
$comentario = $_POST['comentario'];
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->load( 'comentarios.xml' );
$xpath = new DOMXPath($doc);
$doc->formatOutput = true;
$query="//[@idFiesta=$idFiesta]";
$element = $xpath->query($query);
$nodo =$element->item(0);
$nodo.appendChild($doc->createTextNode( $comment[$comentario]));
$doc->save('comentarios.xml');
?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Comentarios>
<Comentario idFiesta="1">
<coment>me gusto mucho</coment>
</Comentario>
</Comentarios>
It was a post message, i wat to insert a comment if the id is the same. I have an error in the query and in the appendChild() I thik. Thanks!
No comments:
Post a Comment