Hi Ng,
a error occurs in my class Articles in which i try to add an element
to an existing xml-file.
$var_dump($chan nels) >>>object(DOMNO deList)+6 (0) {}
$var_dump($chan nels->length) >>>int(0)
$var_dump($chan nels->item(0)) >>>NULL
The tag article exists in the xml-file but it were not found by method
getElementsByTa gName.
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::__contr uct('1.0','utf-8');
}
public function addArticle($tit le, $text)
{
$newItem = $this->createElement( 'item');
$newTitle = $this->createElement( 'title');
$newTitle->appendChild($t his->createTextNode ($title));
$newItem->appendChild($n ewTitle);
$newText = $this->createCDATASec tion($text);
$newItem->appendChilde($ newText);
$channels = $this->getElementsByT agName('article s');
//hier bekomme ich den Fehler, obwohl es den Tag "arcticles" gibt
$channels->item(0)->appendChild($n ewItem);
//andere Ideen wie ich einen neuen Text in einer bestehender xml-
Datei
anhängen kann?
}
}
a error occurs in my class Articles in which i try to add an element
to an existing xml-file.
$var_dump($chan nels) >>>object(DOMNO deList)+6 (0) {}
$var_dump($chan nels->length) >>>int(0)
$var_dump($chan nels->item(0)) >>>NULL
The tag article exists in the xml-file but it were not found by method
getElementsByTa gName.
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::__contr uct('1.0','utf-8');
}
public function addArticle($tit le, $text)
{
$newItem = $this->createElement( 'item');
$newTitle = $this->createElement( 'title');
$newTitle->appendChild($t his->createTextNode ($title));
$newItem->appendChild($n ewTitle);
$newText = $this->createCDATASec tion($text);
$newItem->appendChilde($ newText);
$channels = $this->getElementsByT agName('article s');
//hier bekomme ich den Fehler, obwohl es den Tag "arcticles" gibt
$channels->item(0)->appendChild($n ewItem);
//andere Ideen wie ich einen neuen Text in einer bestehender xml-
Datei
anhängen kann?
}
}
Comment