|
Posted by ibidrin on 04/03/07 15:39
Hi Ng,
a error occurs in my class Articles in which i try to add an element
to an existing xml-file.
$var_dump($channels) >>>> object(DOMNOdeList)+6 (0) {}
$var_dump($channels->length) >>>> int(0)
$var_dump($channels->item(0)) >>>> NULL
The tag article exists in the xml-file but it were not found by method
getElementsByTagName.
Following error were occur:
Fatal error: Call to a member function appendChild() on a non-object
in ...
Any suggestions?
class Article extends DomDocument
{
public function __contruct()
{
parent::__contruct('1.0','utf-8');
}
public function addArticle($title, $text)
{
$newItem = $this->createElement('item');
$newTitle = $this->createElement('title');
$newTitle->appendChild($this->createTextNode($title));
$newItem->appendChild($newTitle);
$newText = $this->createCDATASection($text);
$newItem->appendChilde($newText);
$channels = $this->getElementsByTagName('articles');
//hier bekomme ich den Fehler, obwohl es den Tag "arcticles" gibt
$channels->item(0)->appendChild($newItem);
//andere Ideen wie ich einen neuen Text in einer bestehender xml-
Datei
anhängen kann?
}
}
Navigation:
[Reply to this message]
|