remover elemento do xml
Olá,
tenho um xml com a seguinte estrutura:
<tickers>
<ticker>
<tipo>teste</tipo>
<titulo>testet</titulo>
<texto>tx1</texto>
<foto>test1.jpg</foto>
<datainicio>24/6/2013</datainicio>
<datafim>25/6/2013</datafim>
</ticker>
<ticker>
<tipo>teste</tipo>
<titulo>testet</titulo>
<texto>tx2</texto>
<foto>test2.jpg</foto>
<credito>c2</credito>
<datainicio>24/6/2013</datainicio>
<datafim>25/6/2013</datafim>
</ticker>
</tickers>
E quero remover um dos <ticker>. Para isso estou usando o seguinde código:
$titulo = $_POST['titulo'];
$doc = new DOMDocument();
$doc->load( 'news_slider/xml/xml01.xml' );
$books = $doc->getElementsByTagName( "ticker" );
foreach( $books as $book )
{
$chapter = $book->getElementsByTagName( "titulo" );
$authors = $book->getElementsByTagName( "titulo" );
$author = $authors->item(0)->nodeValue;
if($author = $titulo){
$oldchapter = $doc->removeChild($books);
echo $doc->saveXML();
}
}
MAS está dando o erro:
Catchable fatal error: Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, instance of DOMNodeList given in /home/siste592/public_html/slider_jetmob/flash/excluirN.php on line 16
A linha 16:
$oldchapter = $doc->removeChild($books);
Alguém pode me ajudar?
Discussão (4)
Carregando comentários...